diff --git a/scripts/processDiagnosticMessages.ts b/scripts/processDiagnosticMessages.ts index 4bdf3ca0178..7577707340a 100644 --- a/scripts/processDiagnosticMessages.ts +++ b/scripts/processDiagnosticMessages.ts @@ -6,6 +6,7 @@ interface DiagnosticDetails { code: number; reportsUnnecessary?: {}; isEarly?: boolean; + elidedInCompatabilityPyramid?: boolean; } type InputDiagnosticMessageTable = Map; @@ -63,14 +64,15 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, inputFil "// generated from '" + inputFilePathRel + "' by '" + thisFilePathRel.replace(/\\/g, "/") + "'\r\n" + "/* @internal */\r\n" + "namespace ts {\r\n" + - " function diag(code: number, category: DiagnosticCategory, key: string, message: string, reportsUnnecessary?: {}): DiagnosticMessage {\r\n" + - " return { code, category, key, message, reportsUnnecessary };\r\n" + + " function diag(code: number, category: DiagnosticCategory, key: string, message: string, reportsUnnecessary?: {}, elidedInCompatabilityPyramid?: boolean): DiagnosticMessage {\r\n" + + " return { code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid };\r\n" + " }\r\n" + " export const Diagnostics = {\r\n"; - messageTable.forEach(({ code, category, reportsUnnecessary }, name) => { + messageTable.forEach(({ code, category, reportsUnnecessary, elidedInCompatabilityPyramid }, name) => { const propName = convertPropertyName(name); const argReportsUnnecessary = reportsUnnecessary ? `, /*reportsUnnecessary*/ ${reportsUnnecessary}` : ""; - result += ` ${propName}: diag(${code}, DiagnosticCategory.${category}, "${createKey(propName, code)}", ${JSON.stringify(name)}${argReportsUnnecessary}),\r\n`; + const argElidedInCompatabilityPyramid = elidedInCompatabilityPyramid ? `${!reportsUnnecessary ? ", /*reportsUnnecessary*/ undefined" : ""}, /*elidedInCompatabilityPyramid*/ ${elidedInCompatabilityPyramid}` : ""; + result += ` ${propName}: diag(${code}, DiagnosticCategory.${category}, "${createKey(propName, code)}", ${JSON.stringify(name)}${argReportsUnnecessary}${argElidedInCompatabilityPyramid}),\r\n`; }); result += " };\r\n}"; diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 705ec3b75f4..1d6627987e1 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -564,7 +564,7 @@ namespace ts { if (!isIIFE) { currentFlow = { flags: FlowFlags.Start }; if (containerFlags & (ContainerFlags.IsFunctionExpression | ContainerFlags.IsObjectLiteralOrClassExpressionMethod)) { - currentFlow.container = node; + currentFlow.node = node; } } // We create a return control flow graph for IIFEs and constructors. For constructors @@ -581,6 +581,7 @@ namespace ts { if (!(currentFlow.flags & FlowFlags.Unreachable) && containerFlags & ContainerFlags.IsFunctionLike && nodeIsPresent((node).body)) { node.flags |= NodeFlags.HasImplicitReturn; if (hasExplicitReturn) node.flags |= NodeFlags.HasExplicitReturn; + (node).endFlowNode = currentFlow; } if (node.kind === SyntaxKind.SourceFile) { node.flags |= emitFlags; @@ -671,6 +672,9 @@ namespace ts { bindJSDoc(node); return; } + if (node.kind >= SyntaxKind.FirstStatement && node.kind <= SyntaxKind.LastStatement && !options.allowUnreachableCode) { + node.flowNode = currentFlow; + } switch (node.kind) { case SyntaxKind.WhileStatement: bindWhileStatement(node); @@ -708,6 +712,9 @@ namespace ts { case SyntaxKind.CaseClause: bindCaseClause(node); break; + case SyntaxKind.ExpressionStatement: + bindExpressionStatement(node); + break; case SyntaxKind.LabeledStatement: bindLabeledStatement(node); break; @@ -845,17 +852,11 @@ namespace ts { } function createBranchLabel(): FlowLabel { - return { - flags: FlowFlags.BranchLabel, - antecedents: undefined - }; + return { flags: FlowFlags.BranchLabel, antecedents: undefined }; } function createLoopLabel(): FlowLabel { - return { - flags: FlowFlags.LoopLabel, - antecedents: undefined - }; + return { flags: FlowFlags.LoopLabel, antecedents: undefined }; } function setFlowNodeReferenced(flow: FlowNode) { @@ -885,7 +886,7 @@ namespace ts { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags, expression, antecedent }); + return flowNodeCreated({ flags, antecedent, node: expression }); } function createFlowSwitchClause(antecedent: FlowNode, switchStatement: SwitchStatement, clauseStart: number, clauseEnd: number): FlowNode { @@ -893,7 +894,7 @@ namespace ts { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: FlowFlags.SwitchClause, switchStatement, clauseStart, clauseEnd, antecedent }); + return flowNodeCreated({ flags: FlowFlags.SwitchClause, antecedent, switchStatement, clauseStart, clauseEnd }); } function createFlowAssignment(antecedent: FlowNode, node: Expression | VariableDeclaration | BindingElement): FlowNode { @@ -901,10 +902,14 @@ namespace ts { return flowNodeCreated({ flags: FlowFlags.Assignment, antecedent, node }); } + function createFlowCall(antecedent: FlowNode, node: CallExpression): FlowNode { + setFlowNodeReferenced(antecedent); + return flowNodeCreated({ flags: FlowFlags.Call, antecedent, node }); + } + function createFlowArrayMutation(antecedent: FlowNode, node: CallExpression | BinaryExpression): FlowNode { setFlowNodeReferenced(antecedent); - const res: FlowArrayMutation = flowNodeCreated({ flags: FlowFlags.ArrayMutation, antecedent, node }); - return res; + return flowNodeCreated({ flags: FlowFlags.ArrayMutation, antecedent, node }); } function finishFlowLabel(flow: FlowLabel): FlowNode { @@ -1030,12 +1035,12 @@ namespace ts { function bindForInOrForOfStatement(node: ForInOrOfStatement): void { const preLoopLabel = createLoopLabel(); const postLoopLabel = createBranchLabel(); + bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; if (node.kind === SyntaxKind.ForOfStatement) { bind(node.awaitModifier); } - bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); if (node.initializer.kind !== SyntaxKind.VariableDeclarationList) { @@ -1222,7 +1227,8 @@ namespace ts { addAntecedent(postSwitchLabel, currentFlow); const hasDefault = forEach(node.caseBlock.clauses, c => c.kind === SyntaxKind.DefaultClause); // We mark a switch statement as possibly exhaustive if it has no default clause and if all - // case clauses have unreachable end points (e.g. they all return). + // case clauses have unreachable end points (e.g. they all return). Note, we no longer need + // this property in control flow analysis, it's there only for backwards compatibility. node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -1281,6 +1287,24 @@ namespace ts { activeLabels!.pop(); } + function isDottedName(node: Expression): boolean { + return node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.ThisKeyword || + node.kind === SyntaxKind.PropertyAccessExpression && isDottedName((node).expression) || + node.kind === SyntaxKind.ParenthesizedExpression && isDottedName((node).expression); + } + + function bindExpressionStatement(node: ExpressionStatement): void { + bind(node.expression); + // A top level call expression with a dotted function name and at least one argument + // is potentially an assertion and is therefore included in the control flow. + if (node.expression.kind === SyntaxKind.CallExpression) { + const call = node.expression; + if (isDottedName(call.expression)) { + currentFlow = createFlowCall(currentFlow, call); + } + } + } + function bindLabeledStatement(node: LabeledStatement): void { const preStatementLabel = createLoopLabel(); const postStatementLabel = createBranchLabel(); diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index 36521a14eae..7451eb678b4 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -425,7 +425,7 @@ namespace ts { const options = program.getCompilerOptions(); forEach(program.getSourceFiles(), f => program.isSourceFileDefaultLibrary(f) && - !skipTypeChecking(f, options) && + !skipTypeChecking(f, options, program) && removeSemanticDiagnosticsOf(state, f.path) ); } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 067408f90c3..7f3c1cfc43d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -382,6 +382,7 @@ namespace ts { getReturnTypeOfSignature, getNullableType, getNonNullableType, + getTypeArguments, typeToTypeNode: nodeBuilder.typeToTypeNode, indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration, signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration, @@ -507,6 +508,7 @@ namespace ts { getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, + getTypeArguments, ), getAmbientModules, getJsxIntrinsicTagNamesAt, @@ -523,6 +525,9 @@ namespace ts { }, getApparentType, getUnionType, + isTypeAssignableTo: (source, target) => { + return isTypeAssignableTo(source, target); + }, createAnonymousType, createSignature, createSymbol, @@ -569,7 +574,7 @@ namespace ts { return node && getTypeArgumentConstraint(node); }, getSuggestionDiagnostics: (file, ct) => { - if (skipTypeChecking(file, compilerOptions)) { + if (skipTypeChecking(file, compilerOptions, host)) { return emptyArray; } @@ -672,6 +677,7 @@ namespace ts { const silentNeverType = createIntrinsicType(TypeFlags.Never, "never"); const nonInferrableType = createIntrinsicType(TypeFlags.Never, "never", ObjectFlags.NonInferrableType); const implicitNeverType = createIntrinsicType(TypeFlags.Never, "never"); + const unreachableNeverType = createIntrinsicType(TypeFlags.Never, "never"); const nonPrimitiveType = createIntrinsicType(TypeFlags.NonPrimitive, "object"); const stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); const keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; @@ -702,7 +708,7 @@ namespace ts { markerSubType.constraint = markerSuperType; const markerOtherType = createTypeParameter(); - const noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); + const noTypePredicate = createTypePredicate(TypePredicateKind.Identifier, "<>", 0, anyType); const anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); const unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); @@ -821,6 +827,8 @@ namespace ts { let sharedFlowCount = 0; let flowAnalysisDisabled = false; let flowInvocationCount = 0; + let lastFlowNode: FlowNode | undefined; + let lastFlowNodeReachable: boolean; const emptyStringType = getLiteralType(""); const zeroType = getLiteralType(0); @@ -842,6 +850,7 @@ namespace ts { const flowLoopTypes: Type[][] = []; const sharedFlowNodes: FlowNode[] = []; const sharedFlowTypes: FlowType[] = []; + const flowNodeReachable: (boolean | undefined)[] = []; const potentialThisCollisions: Node[] = []; const potentialNewTargetCollisions: Node[] = []; const awaitedTypeStack: number[] = []; @@ -3722,11 +3731,17 @@ namespace ts { return createThis(); } + if (!inTypeAlias && type.aliasSymbol && (context.flags & NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & SymbolFlags.Class)) return createTypeReferenceNode(createIdentifier(""), typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, SymbolFlags.Type, typeArgumentNodes); + } + const objectFlags = getObjectFlags(type); if (objectFlags & ObjectFlags.Reference) { Debug.assert(!!(type.flags & TypeFlags.Object)); - return typeReferenceToTypeNode(type); + return (type).node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } if (type.flags & TypeFlags.TypeParameter || objectFlags & ObjectFlags.ClassOrInterface) { if (type.flags & TypeFlags.TypeParameter && contains(context.inferTypeParameters, type)) { @@ -3744,11 +3759,6 @@ namespace ts { ? symbolToTypeNode(type.symbol, context, SymbolFlags.Type) : createTypeReferenceNode(createIdentifier("?"), /*typeArguments*/ undefined); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { - const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & SymbolFlags.Class)) return createTypeReferenceNode(createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, SymbolFlags.Type, typeArgumentNodes); - } if (type.flags & (TypeFlags.Union | TypeFlags.Intersection)) { const types = type.flags & TypeFlags.Union ? formatUnionTypes((type).types) : (type).types; if (length(types) === 1) { @@ -3823,10 +3833,7 @@ namespace ts { function createAnonymousTypeNode(type: ObjectType): TypeNode { const typeId = "" + type.id; const symbol = type.symbol; - let id: string; if (symbol) { - const isConstructorObject = getObjectFlags(type) & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & SymbolFlags.Class; - id = (isConstructorObject ? "+" : "") + getSymbolId(symbol); if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. const isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? SymbolFlags.Type : SymbolFlags.Value; @@ -3850,25 +3857,7 @@ namespace ts { } } else { - // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead - // of types allows us to catch circular references to instantiations of the same anonymous type - if (!context.visitedTypes) { - context.visitedTypes = createMap(); - } - if (!context.symbolDepth) { - context.symbolDepth = createMap(); - } - - const depth = context.symbolDepth.get(id) || 0; - if (depth > 10) { - return createElidedInformationPlaceholder(context); - } - context.symbolDepth.set(id, depth + 1); - context.visitedTypes.set(typeId, true); - const result = createTypeNodeFromObjectType(type); - context.visitedTypes.delete(typeId); - context.symbolDepth.set(id, depth); - return result; + return visitAndTransformType(type, createTypeNodeFromObjectType); } } else { @@ -3890,6 +3879,38 @@ namespace ts { } } + function visitAndTransformType(type: Type, transform: (type: Type) => T) { + const typeId = "" + type.id; + const isConstructorObject = getObjectFlags(type) & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & SymbolFlags.Class; + const id = getObjectFlags(type) & ObjectFlags.Reference && (type).node ? "N" + getNodeId((type).node!) : + type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : + undefined; + // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead + // of types allows us to catch circular references to instantiations of the same anonymous type + if (!context.visitedTypes) { + context.visitedTypes = createMap(); + } + if (id && !context.symbolDepth) { + context.symbolDepth = createMap(); + } + + let depth: number | undefined; + if (id) { + depth = context.symbolDepth!.get(id) || 0; + if (depth > 10) { + return createElidedInformationPlaceholder(context); + } + context.symbolDepth!.set(id, depth + 1); + } + context.visitedTypes.set(typeId, true); + const result = transform(type); + context.visitedTypes.delete(typeId); + if (id) { + context.symbolDepth!.set(id, depth!); + } + return result; + } + function createTypeNodeFromObjectType(type: ObjectType): TypeNode { if (isGenericMappedType(type)) { return createMappedTypeNodeFromType(type); @@ -3926,13 +3947,12 @@ namespace ts { } function typeReferenceToTypeNode(type: TypeReference) { - const typeArguments: readonly Type[] = type.typeArguments || emptyArray; + const typeArguments: readonly Type[] = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { if (context.flags & NodeBuilderFlags.WriteArrayAsGenericType) { const typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); return createTypeReferenceNode(type.target === globalArrayType ? "Array" : "ReadonlyArray", [typeArgumentNode]); } - const elementType = typeToTypeNodeHelper(typeArguments[0], context); const arrayType = createArrayTypeNode(elementType); return type.target === globalArrayType ? arrayType : createTypeOperatorNode(SyntaxKind.ReadonlyKeyword, arrayType); @@ -4247,11 +4267,14 @@ namespace ts { let returnTypeNode: TypeNode | undefined; const typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - const parameterName = typePredicate.kind === TypePredicateKind.Identifier ? + const assertsModifier = typePredicate.kind === TypePredicateKind.AssertsThis || typePredicate.kind === TypePredicateKind.AssertsIdentifier ? + createToken(SyntaxKind.AssertsKeyword) : + undefined; + const parameterName = typePredicate.kind === TypePredicateKind.Identifier || typePredicate.kind === TypePredicateKind.AssertsIdentifier ? setEmitFlags(createIdentifier(typePredicate.parameterName), EmitFlags.NoAsciiEscaping) : createThisTypeNode(); - const typeNode = typeToTypeNodeHelper(typePredicate.type, context); - returnTypeNode = createTypePredicateNode(parameterName, typeNode); + const typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); + returnTypeNode = createTypePredicateNodeWithModifier(assertsModifier, parameterName, typeNode); } else { const returnType = getReturnTypeOfSignature(signature); @@ -4718,9 +4741,10 @@ namespace ts { return writer ? typePredicateToStringWorker(writer).getText() : usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer: EmitTextWriter) { - const predicate = createTypePredicateNode( - typePredicate.kind === TypePredicateKind.Identifier ? createIdentifier(typePredicate.parameterName) : createThisTypeNode(), - nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | NodeBuilderFlags.IgnoreErrors | NodeBuilderFlags.WriteTypeParametersInQualifiedName)!, // TODO: GH#18217 + const predicate = createTypePredicateNodeWithModifier( + typePredicate.kind === TypePredicateKind.AssertsThis || typePredicate.kind === TypePredicateKind.AssertsIdentifier ? createToken(SyntaxKind.AssertsKeyword) : undefined, + typePredicate.kind === TypePredicateKind.Identifier || typePredicate.kind === TypePredicateKind.AssertsIdentifier ? createIdentifier(typePredicate.parameterName) : createThisTypeNode(), + typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | NodeBuilderFlags.IgnoreErrors | NodeBuilderFlags.WriteTypeParametersInQualifiedName)! // TODO: GH#18217 ); const printer = createPrinter({ removeComments: true }); const sourceFile = enclosingDeclaration && getSourceFileOfNode(enclosingDeclaration); @@ -5985,7 +6009,9 @@ namespace ts { function getBaseTypeVariableOfClass(symbol: Symbol) { const baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & TypeFlags.TypeVariable ? baseConstructorType : undefined; + return baseConstructorType.flags & TypeFlags.TypeVariable ? baseConstructorType : + baseConstructorType.flags & TypeFlags.Intersection ? find((baseConstructorType as IntersectionType).types, t => !!(t.flags & TypeFlags.TypeVariable)) : + undefined; } function getTypeOfFuncClassEnumModule(symbol: Symbol): Type { @@ -6257,18 +6283,18 @@ namespace ts { const signatures = getSignaturesOfType(type, SignatureKind.Construct); if (signatures.length === 1) { const s = signatures[0]; - return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getElementTypeOfArrayType(getTypeOfParameter(s.parameters[0])) === anyType; } return false; } function isConstructorType(type: Type): boolean { - if (isValidBaseType(type) && getSignaturesOfType(type, SignatureKind.Construct).length > 0) { + if (getSignaturesOfType(type, SignatureKind.Construct).length > 0) { return true; } if (type.flags & TypeFlags.TypeVariable) { const constraint = getBaseConstraintOfType(type); - return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); + return !!constraint && isMixinConstructorType(constraint); } return false; } @@ -6370,7 +6396,6 @@ namespace ts { return type.resolvedBaseTypes = emptyArray; } const baseTypeNode = getBaseTypeNodeOfClass(type)!; - const typeArgs = typeArgumentsFromTypeReferenceNode(baseTypeNode); let baseType: Type; const originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; if (baseConstructorType.symbol && baseConstructorType.symbol.flags & SymbolFlags.Class && @@ -6378,7 +6403,7 @@ namespace ts { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. - baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol, typeArgs); + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } else if (baseConstructorType.flags & TypeFlags.Any) { baseType = baseConstructorType; @@ -6423,15 +6448,22 @@ namespace ts { const outerTypeParameters = (type).outerTypeParameters; if (outerTypeParameters) { const last = outerTypeParameters.length - 1; - const typeArguments = (type).typeArguments!; + const typeArguments = getTypeArguments(type); return outerTypeParameters[last].symbol !== typeArguments[last].symbol; } return true; } - // A valid base type is `any`, any non-generic object type or intersection of non-generic - // object types. + // A valid base type is `any`, an object type or intersection of object types. function isValidBaseType(type: Type): type is BaseType { + if (type.flags & TypeFlags.TypeParameter) { + const constraint = getBaseConstraintOfType(type); + if (constraint) { + return isValidBaseType(constraint); + } + } + // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? + // There's no reason a `T` should be allowed while a `Readonly` should not. return !!(type.flags & (TypeFlags.Object | TypeFlags.NonPrimitive | TypeFlags.Any)) && !isGenericMappedType(type) || !!(type.flags & TypeFlags.Intersection) && every((type).types, isValidBaseType); } @@ -6521,7 +6553,7 @@ namespace ts { (type).instantiations = createMap(); (type).instantiations.set(getTypeListId(type.typeParameters), type); (type).target = type; - (type).typeArguments = type.typeParameters; + (type).resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(symbol); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -7045,7 +7077,7 @@ namespace ts { function getTypeWithThisArgument(type: Type, thisArgument?: Type, needApparentType?: boolean): Type { if (getObjectFlags(type) & ObjectFlags.Reference) { const target = (type).target; - const typeArguments = (type).typeArguments; + const typeArguments = getTypeArguments(type); if (length(target.typeParameters) === length(typeArguments)) { const ref = createTypeReference(target, concatenate(typeArguments, [thisArgument || target.thisType!])); return needApparentType ? getApparentType(ref) : ref; @@ -7110,9 +7142,9 @@ namespace ts { function resolveTypeReferenceMembers(type: TypeReference): void { const source = resolveDeclaredMembers(type.target); const typeParameters = concatenate(source.typeParameters!, [source.thisType!]); - const typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? - type.typeArguments : concatenate(type.typeArguments, [type]); - resolveObjectTypeMembers(type, source, typeParameters, typeArguments); + const typeArguments = getTypeArguments(type); + const paddedTypeArguments = typeArguments.length === typeParameters.length ? typeArguments : concatenate(typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, paddedTypeArguments); } function createSignature( @@ -7163,7 +7195,7 @@ namespace ts { const restParameter = sig.parameters[restIndex]; const restType = getTypeOfSymbol(restParameter); if (isTupleType(restType)) { - const elementTypes = restType.typeArguments || emptyArray; + const elementTypes = getTypeArguments(restType); const minLength = restType.target.minLength; const tupleRestIndex = restType.target.hasRestElement ? elementTypes.length - 1 : -1; const restParams = map(elementTypes, (t, i) => { @@ -7956,10 +7988,10 @@ namespace ts { return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined; } - function getUnionConstraintOfIntersection(type: IntersectionType, targetIsUnion: boolean) { + function getEffectiveConstraintOfIntersection(types: readonly Type[], targetIsUnion: boolean) { let constraints: Type[] | undefined; let hasDisjointDomainType = false; - for (const t of type.types) { + for (const t of types) { if (t.flags & TypeFlags.Instantiable) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). @@ -7969,6 +8001,9 @@ namespace ts { } if (constraint) { constraints = append(constraints, constraint); + if (targetIsUnion) { + constraints = append(constraints, t); + } } } else if (t.flags & TypeFlags.DisjointDomains) { @@ -7981,7 +8016,7 @@ namespace ts { if (hasDisjointDomainType) { // We add any types belong to one of the disjoint domains because they might cause the final // intersection operation to reduce the union constraints. - for (const t of type.types) { + for (const t of types) { if (t.flags & TypeFlags.DisjointDomains) { constraints = append(constraints, t); } @@ -8485,12 +8520,8 @@ namespace ts { return isBracketed || !!typeExpression && typeExpression.type.kind === SyntaxKind.JSDocOptionalType; } - function createIdentifierTypePredicate(parameterName: string, parameterIndex: number, type: Type): IdentifierTypePredicate { - return { kind: TypePredicateKind.Identifier, parameterName, parameterIndex, type }; - } - - function createThisTypePredicate(type: Type): ThisTypePredicate { - return { kind: TypePredicateKind.This, type }; + function createTypePredicate(kind: TypePredicateKind, parameterName: string | undefined, parameterIndex: number | undefined, type: Type | undefined): TypePredicate { + return { kind, parameterName, parameterIndex, type } as TypePredicate; } /** @@ -8725,10 +8756,6 @@ namespace ts { } } - function signatureHasTypePredicate(signature: Signature): boolean { - return getTypePredicateOfSignature(signature) !== undefined; - } - function getTypePredicateOfSignature(signature: Signature): TypePredicate | undefined { if (!signature.resolvedTypePredicate) { if (signature.target) { @@ -8756,18 +8783,13 @@ namespace ts { return signature.resolvedTypePredicate === noTypePredicate ? undefined : signature.resolvedTypePredicate; } - 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, - findIndex(signature.parameters, p => p.escapedName === parameterName.escapedText), - type); - } - else { - return createThisTypePredicate(type); - } + function createTypePredicateFromTypePredicateNode(node: TypePredicateNode, signature: Signature): TypePredicate { + const parameterName = node.parameterName; + const type = node.type && getTypeFromTypeNode(node.type); + return parameterName.kind === SyntaxKind.ThisType ? + createTypePredicate(node.assertsModifier ? TypePredicateKind.AssertsThis : TypePredicateKind.This, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : + createTypePredicate(node.assertsModifier ? TypePredicateKind.AssertsIdentifier : TypePredicateKind.Identifier, parameterName.escapedText as string, + findIndex(signature.parameters, p => p.escapedName === parameterName.escapedText), type); } function getReturnTypeOfSignature(signature: Signature): Type { @@ -9088,7 +9110,7 @@ namespace ts { target.instantiations.set(id, type); type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; - type.typeArguments = typeArguments; + type.resolvedTypeArguments = typeArguments; } return type; } @@ -9098,18 +9120,43 @@ namespace ts { type.symbol = source.symbol; type.objectFlags = source.objectFlags; type.target = source.target; - type.typeArguments = source.typeArguments; + type.resolvedTypeArguments = source.resolvedTypeArguments; return type; } + function createDeferredTypeReference(target: GenericType, node: TypeReferenceNode | ArrayTypeNode | TupleTypeNode, mapper?: TypeMapper): DeferredTypeReference { + const aliasSymbol = getAliasSymbolForTypeNode(node); + const aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + const type = createObjectType(ObjectFlags.Reference, target.symbol); + type.target = target; + type.node = node; + type.mapper = mapper; + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments; + return type; + } + + function getTypeArguments(type: TypeReference): readonly Type[] { + if (!type.resolvedTypeArguments) { + const node = type.node; + const typeArguments = !node ? emptyArray : + node.kind === SyntaxKind.TypeReference ? concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters!)) : + node.kind === SyntaxKind.ArrayType ? [getTypeFromTypeNode(node.elementType)] : + map(node.elementTypes, getTypeFromTypeNode); + type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; + } + return type.resolvedTypeArguments; + } + function getTypeReferenceArity(type: TypeReference): number { return length(type.target.typeParameters); } + /** * Get type from type-reference that reference to class or interface */ - function getTypeFromClassOrInterfaceReference(node: NodeWithTypeArguments, symbol: Symbol, typeArgs: Type[] | undefined): Type { + function getTypeFromClassOrInterfaceReference(node: NodeWithTypeArguments, symbol: Symbol): Type { const type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); const typeParameters = type.localTypeParameters; if (typeParameters) { @@ -9134,10 +9181,13 @@ namespace ts { return errorType; } } + if (node.kind === SyntaxKind.TypeReference && isAliasedType(node)) { + return createDeferredTypeReference(type, node, /*mapper*/ undefined); + } // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - const typeArguments = concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJs)); + const typeArguments = concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgumentsFromTypeReferenceNode(node), typeParameters, minTypeArgumentCount, isJs)); return createTypeReference(type, typeArguments); } return checkNoTypeArguments(node, symbol) ? type : errorType; @@ -9160,7 +9210,7 @@ namespace ts { * references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ - function getTypeFromTypeAliasReference(node: NodeWithTypeArguments, symbol: Symbol, typeArguments: Type[] | undefined): Type { + function getTypeFromTypeAliasReference(node: NodeWithTypeArguments, symbol: Symbol): Type { const type = getDeclaredTypeOfSymbol(symbol); const typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { @@ -9176,7 +9226,7 @@ namespace ts { typeParameters.length); return errorType; } - return getTypeAliasInstantiation(symbol, typeArguments); + return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node)); } return checkNoTypeArguments(node, symbol) ? type : errorType; } @@ -9207,19 +9257,16 @@ namespace ts { } function getTypeReferenceType(node: NodeWithTypeArguments, symbol: Symbol): Type { - const typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. if (symbol === unknownSymbol) { return errorType; } symbol = getExpandoSymbol(symbol) || symbol; - if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { - return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); + return getTypeFromClassOrInterfaceReference(node, symbol); } if (symbol.flags & SymbolFlags.TypeAlias) { - return getTypeFromTypeAliasReference(node, symbol, typeArguments); + return getTypeFromTypeAliasReference(node, symbol); } - // Get type from reference to named type that cannot be generic (enum or type parameter) const res = tryGetDeclaredTypeOfSymbol(symbol); if (res) { @@ -9227,7 +9274,6 @@ namespace ts { res.flags & TypeFlags.TypeParameter ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } - if (symbol.flags & SymbolFlags.Value && isJSDocTypeReference(node)) { const jsdocType = getTypeFromJSAlias(node, symbol); if (jsdocType) { @@ -9239,7 +9285,6 @@ namespace ts { return getTypeOfSymbol(symbol); } } - return errorType; } @@ -9573,10 +9618,52 @@ namespace ts { return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]); } - function getTypeFromArrayTypeNode(node: ArrayTypeNode): Type { + function getArrayOrTupleTargetType(node: ArrayTypeNode | TupleTypeNode): GenericType { + const readonly = isReadonlyTypeOperator(node.parent); + if (node.kind === SyntaxKind.ArrayType || node.elementTypes.length === 1 && node.elementTypes[0].kind === SyntaxKind.RestType) { + return readonly ? globalReadonlyArrayType : globalArrayType; + } + const lastElement = lastOrUndefined(node.elementTypes); + const restElement = lastElement && lastElement.kind === SyntaxKind.RestType ? lastElement : undefined; + const minLength = findLastIndex(node.elementTypes, n => n.kind !== SyntaxKind.OptionalType && n !== restElement) + 1; + return getTupleTypeOfArity(node.elementTypes.length, minLength, !!restElement, readonly, /*associatedNames*/ undefined); + } + + // Return true when the given node is transitively contained in type constructs that eagerly + // resolve their constituent types. We include SyntaxKind.TypeReference because type arguments + // of type aliases are eagerly resolved. + function isAliasedType(node: Node): boolean { + const parent = node.parent; + switch (parent.kind) { + case SyntaxKind.ParenthesizedType: + case SyntaxKind.TypeReference: + case SyntaxKind.UnionType: + case SyntaxKind.IntersectionType: + case SyntaxKind.IndexedAccessType: + case SyntaxKind.ConditionalType: + case SyntaxKind.TypeOperator: + return isAliasedType(parent); + case SyntaxKind.TypeAliasDeclaration: + return true; + } + return false; + } + + function getTypeFromArrayOrTupleTypeNode(node: ArrayTypeNode | TupleTypeNode): Type { const links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType), isReadonlyTypeOperator(node.parent)); + const target = getArrayOrTupleTargetType(node); + if (target === emptyGenericType) { + links.resolvedType = emptyObjectType; + } + else if (isAliasedType(node)) { + links.resolvedType = node.kind === SyntaxKind.TupleType && node.elementTypes.length === 0 ? target : + createDeferredTypeReference(target, node, /*mapper*/ undefined); + } + else { + const elementTypes = node.kind === SyntaxKind.ArrayType ? [getTypeFromTypeNode(node.elementType)] : map(node.elementTypes, getTypeFromTypeNode); + links.resolvedType = createTypeReference(target, elementTypes); + } } return links.resolvedType; } @@ -9620,7 +9707,7 @@ namespace ts { type.instantiations = createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -9654,21 +9741,6 @@ namespace ts { return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } - function getTypeFromTupleTypeNode(node: TupleTypeNode): Type { - const links = getNodeLinks(node); - if (!links.resolvedType) { - const lastElement = lastOrUndefined(node.elementTypes); - const restElement = lastElement && lastElement.kind === SyntaxKind.RestType ? lastElement : undefined; - const minLength = findLastIndex(node.elementTypes, n => n.kind !== SyntaxKind.OptionalType && n !== restElement) + 1; - const elementTypes = map(node.elementTypes, n => { - const type = getTypeFromTypeNode(n); - return n === restElement && getIndexTypeOfType(type, IndexKind.Number) || type; - }); - links.resolvedType = createTupleType(elementTypes, minLength, !!restElement, isReadonlyTypeOperator(node.parent)); - } - return links.resolvedType; - } - function sliceTupleType(type: TupleTypeReference, index: number) { const tuple = type.target; if (tuple.hasRestElement) { @@ -9676,7 +9748,7 @@ namespace ts { index = Math.min(index, getTypeReferenceArity(type) - 1); } return createTupleType( - (type.typeArguments || emptyArray).slice(index), + getTypeArguments(type).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, @@ -9856,7 +9928,7 @@ namespace ts { const types: Type[] = []; for (const sig of signatures) { const pred = getTypePredicateOfSignature(sig); - if (!pred) { + if (!pred || pred.kind === TypePredicateKind.AssertsThis || pred.kind === TypePredicateKind.AssertsIdentifier) { continue; } @@ -9876,15 +9948,11 @@ namespace ts { return undefined; } const unionType = getUnionType(types); - return isIdentifierTypePredicate(first) - ? createIdentifierTypePredicate(first.parameterName, first.parameterIndex, unionType) - : createThisTypePredicate(unionType); + return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType); } function typePredicateKindsMatch(a: TypePredicate, b: TypePredicate): boolean { - return isIdentifierTypePredicate(a) - ? isIdentifierTypePredicate(b) && a.parameterIndex === b.parameterIndex - : !isIdentifierTypePredicate(b); + return a.kind === b.kind && a.parameterIndex === b.parameterIndex; } // This function assumes the constituent type list is sorted and deduplicated. @@ -11184,15 +11252,14 @@ namespace ts { case SyntaxKind.TypeReference: return getTypeFromTypeReference(node); case SyntaxKind.TypePredicate: - return booleanType; + return (node).assertsModifier ? voidType : booleanType; case SyntaxKind.ExpressionWithTypeArguments: return getTypeFromTypeReference(node); case SyntaxKind.TypeQuery: return getTypeFromTypeQueryNode(node); case SyntaxKind.ArrayType: - return getTypeFromArrayTypeNode(node); case SyntaxKind.TupleType: - return getTypeFromTupleTypeNode(node); + return getTypeFromArrayOrTupleTypeNode(node); case SyntaxKind.OptionalType: return getTypeFromOptionalTypeNode(node); case SyntaxKind.UnionType: @@ -11204,10 +11271,11 @@ namespace ts { case SyntaxKind.JSDocOptionalType: return addOptionality(getTypeFromTypeNode((node as JSDocOptionalType).type)); case SyntaxKind.ParenthesizedType: - case SyntaxKind.RestType: case SyntaxKind.JSDocNonNullableType: case SyntaxKind.JSDocTypeExpression: - return getTypeFromTypeNode((node).type); + return getTypeFromTypeNode((node).type); + case SyntaxKind.RestType: + return getElementTypeOfArrayType(getTypeFromTypeNode((node).type)) || errorType; case SyntaxKind.JSDocVariadicType: return getTypeFromJSDocVariadicType(node as JSDocVariadicType); case SyntaxKind.FunctionType: @@ -11342,21 +11410,8 @@ namespace ts { return result; } - function instantiateTypePredicate(predicate: TypePredicate, mapper: TypeMapper): ThisTypePredicate | IdentifierTypePredicate { - if (isIdentifierTypePredicate(predicate)) { - return { - kind: TypePredicateKind.Identifier, - parameterName: predicate.parameterName, - parameterIndex: predicate.parameterIndex, - type: instantiateType(predicate.type, mapper) - }; - } - else { - return { - kind: TypePredicateKind.This, - type: instantiateType(predicate.type, mapper) - }; - } + function instantiateTypePredicate(predicate: TypePredicate, mapper: TypeMapper): TypePredicate { + return createTypePredicate(predicate.kind, predicate.parameterName, predicate.parameterIndex, instantiateType(predicate.type, mapper)); } function instantiateSignature(signature: Signature, mapper: TypeMapper, eraseTypeParameters?: boolean): Signature { @@ -11417,17 +11472,17 @@ namespace ts { return result; } - function getAnonymousTypeInstantiation(type: AnonymousType, mapper: TypeMapper) { + function getObjectTypeInstantiation(type: AnonymousType | DeferredTypeReference, mapper: TypeMapper) { const target = type.objectFlags & ObjectFlags.Instantiated ? type.target! : type; - const { symbol } = target; - const links = getSymbolLinks(symbol); + const node = type.objectFlags & ObjectFlags.Reference ? (type).node! : type.symbol.declarations[0]; + const links = getNodeLinks(node); let typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type // parameters that are in scope (and therefore potentially referenced). For type literals that // aren't the right hand side of a generic type alias declaration we optimize by reducing the // set of type parameters to those that are possibly referenced in the literal. - let declaration = symbol.declarations[0]; + let declaration = node; if (isInJSFile(declaration)) { const paramTag = findAncestor(declaration, isJSDocParameterTag); if (paramTag) { @@ -11443,7 +11498,7 @@ namespace ts { outerTypeParameters = addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || emptyArray; - typeParameters = symbol.flags & SymbolFlags.TypeLiteral && !target.aliasTypeArguments ? + typeParameters = (target.objectFlags & ObjectFlags.Reference || target.symbol.flags & SymbolFlags.TypeLiteral) && !target.aliasTypeArguments ? filter(typeParameters, tp => isTypeParameterPossiblyReferenced(tp, declaration)) : typeParameters; links.outerTypeParameters = typeParameters; @@ -11456,13 +11511,14 @@ namespace ts { // We are instantiating an anonymous type that has one or more type parameters in scope. Apply the // mapper to the type parameters to produce the effective list of type arguments, and compute the // instantiation cache key from the type IDs of the type arguments. - const combinedMapper = type.objectFlags & ObjectFlags.Instantiated ? combineTypeMappers(type.mapper, mapper) : mapper; - const typeArguments: Type[] = map(typeParameters, combinedMapper); + const typeArguments = map(typeParameters, combineTypeMappers(type.mapper, mapper)); const id = getTypeListId(typeArguments); let result = links.instantiations!.get(id); if (!result) { const newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & ObjectFlags.Mapped ? instantiateMappedType(target, newMapper) : instantiateAnonymousType(target, newMapper); + result = target.objectFlags & ObjectFlags.Reference ? createDeferredTypeReference((type).target, (type).node, newMapper) : + target.objectFlags & ObjectFlags.Mapped ? instantiateMappedType(target, newMapper) : + instantiateAnonymousType(target, newMapper); links.instantiations!.set(id, result); } return result; @@ -11556,7 +11612,7 @@ namespace ts { function instantiateMappedTupleType(tupleType: TupleTypeReference, mappedType: MappedType, mapper: TypeMapper) { const minLength = tupleType.target.minLength; - const elementTypes = map(tupleType.typeArguments || emptyArray, (_, i) => + const elementTypes = map(getTypeArguments(tupleType), (_, i) => instantiateMappedTypeTemplate(mappedType, getLiteralType("" + i), i >= minLength, mapper)); const modifiers = getMappedTypeModifiers(mappedType); const newMinLength = modifiers & MappedTypeModifiers.IncludeOptional ? 0 : @@ -11659,15 +11715,18 @@ namespace ts { // interface, in an object type literal, or in an object literal expression, we may need // to instantiate the type because it might reference a type parameter. return couldContainTypeVariables(type) ? - getAnonymousTypeInstantiation(type, mapper) : type; + getObjectTypeInstantiation(type, mapper) : type; } if (objectFlags & ObjectFlags.Mapped) { - return getAnonymousTypeInstantiation(type, mapper); + return getObjectTypeInstantiation(type, mapper); } if (objectFlags & ObjectFlags.Reference) { - const typeArguments = (type).typeArguments; - const newTypeArguments = instantiateTypes(typeArguments, mapper); - return newTypeArguments !== typeArguments ? createTypeReference((type).target, newTypeArguments) : type; + if ((type).node) { + return getObjectTypeInstantiation(type, mapper); + } + const resolvedTypeArguments = (type).resolvedTypeArguments; + const newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); + return newTypeArguments !== resolvedTypeArguments ? createTypeReference((type).target, newTypeArguments) : type; } return type; } @@ -12320,7 +12379,7 @@ namespace ts { target: Signature, ignoreReturnTypes: boolean): boolean { return compareSignaturesRelated(source, target, CallbackCheck.None, ignoreReturnTypes, /*reportErrors*/ false, - /*errorReporter*/ undefined, compareTypesAssignable) !== Ternary.False; + /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable) !== Ternary.False; } type ErrorReporter = (message: DiagnosticMessage, arg0?: string, arg1?: string) => void; @@ -12343,6 +12402,7 @@ namespace ts { ignoreReturnTypes: boolean, reportErrors: boolean, errorReporter: ErrorReporter | undefined, + incompatibleErrorReporter: ((source: Type, target: Type) => void) | undefined, compareTypes: TypeComparer): Ternary { // TODO (drosen): De-duplicate code between related functions. if (source === target) { @@ -12409,11 +12469,11 @@ namespace ts { // with respect to T. const sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); const targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); - const callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && + const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && (getFalsyFlags(sourceType) & TypeFlags.Nullable) === (getFalsyFlags(targetType) & TypeFlags.Nullable); const related = callbacks ? // TODO: GH#18217 It will work if they're both `undefined`, but not if only one is - compareSignaturesRelated(targetSig!, sourceSig!, strictVariance ? CallbackCheck.Strict : CallbackCheck.Bivariant, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) : + compareSignaturesRelated(targetSig!, sourceSig!, strictVariance ? CallbackCheck.Strict : CallbackCheck.Bivariant, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) : !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { @@ -12459,6 +12519,9 @@ namespace ts { // wouldn't be co-variant for T without this rule. result &= callbackCheck === CallbackCheck.Bivariant && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); + if (!result && reportErrors && incompatibleErrorReporter) { + incompatibleErrorReporter(sourceReturnType, targetReturnType); + } } } @@ -12480,7 +12543,7 @@ namespace ts { return Ternary.False; } - if (source.kind === TypePredicateKind.Identifier) { + if (source.kind === TypePredicateKind.Identifier || source.kind === TypePredicateKind.AssertsIdentifier) { if (source.parameterIndex !== (target as IdentifierTypePredicate).parameterIndex) { if (reportErrors) { errorReporter!(Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, (target as IdentifierTypePredicate).parameterName); @@ -12490,7 +12553,9 @@ namespace ts { } } - const related = compareTypes(source.type, target.type, reportErrors); + const related = source.type === target.type ? Ternary.True : + source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : + Ternary.False; if (related === Ternary.False && reportErrors) { errorReporter!(Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } @@ -12545,12 +12610,12 @@ namespace ts { return true; } const id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); - const relation = enumRelation.get(id); - if (relation !== undefined && !(relation === RelationComparisonResult.Failed && errorReporter)) { - return relation === RelationComparisonResult.Succeeded; + const entry = enumRelation.get(id); + if (entry !== undefined && !(!(entry & RelationComparisonResult.Reported) && entry & RelationComparisonResult.Failed && errorReporter)) { + return !!(entry & RelationComparisonResult.Succeeded); } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & SymbolFlags.RegularEnum) || !(targetSymbol.flags & SymbolFlags.RegularEnum)) { - enumRelation.set(id, RelationComparisonResult.FailedAndReported); + enumRelation.set(id, RelationComparisonResult.Failed | RelationComparisonResult.Reported); return false; } const targetEnumType = getTypeOfSymbol(targetSymbol); @@ -12561,7 +12626,7 @@ namespace ts { if (errorReporter) { errorReporter(Diagnostics.Property_0_is_missing_in_type_1, symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType)); - enumRelation.set(id, RelationComparisonResult.FailedAndReported); + enumRelation.set(id, RelationComparisonResult.Failed | RelationComparisonResult.Reported); } else { enumRelation.set(id, RelationComparisonResult.Failed); @@ -12626,7 +12691,7 @@ namespace ts { if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) { const related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { - return related === RelationComparisonResult.Succeeded; + return !!(related & RelationComparisonResult.Succeeded); } } if (source.flags & TypeFlags.StructuredOrInstantiable || target.flags & TypeFlags.StructuredOrInstantiable) { @@ -12668,11 +12733,16 @@ namespace ts { let depth = 0; let expandingFlags = ExpandingFlags.None; let overflow = false; - let overrideNextErrorInfo: DiagnosticMessageChain | undefined; + let overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid + let lastSkippedInfo: [Type, Type] | undefined; + let incompatibleStack: [DiagnosticMessage, (string | number)?, (string | number)?, (string | number)?, (string | number)?][] = []; Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); const result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage); + if (incompatibleStack.length) { + reportIncompatibleStack(); + } if (overflow) { const diag = error(errorNode, Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { @@ -12717,8 +12787,134 @@ namespace ts { } return result !== Ternary.False; + function resetErrorInfo(saved: ReturnType) { + errorInfo = saved.errorInfo; + lastSkippedInfo = saved.lastSkippedInfo; + incompatibleStack = saved.incompatibleStack; + overrideNextErrorInfo = saved.overrideNextErrorInfo; + relatedInfo = saved.relatedInfo; + } + + function captureErrorCalculationState() { + return { + errorInfo, + lastSkippedInfo, + incompatibleStack: incompatibleStack.slice(), + overrideNextErrorInfo, + relatedInfo: !relatedInfo ? undefined : relatedInfo.slice() as ([DiagnosticRelatedInformation, ...DiagnosticRelatedInformation[]] | undefined) + }; + } + + function reportIncompatibleError(message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number, arg3?: string | number) { + overrideNextErrorInfo++; // Suppress the next relation error + lastSkippedInfo = undefined; // Reset skipped info cache + incompatibleStack.push([message, arg0, arg1, arg2, arg3]); + } + + function reportIncompatibleStack() { + const stack = incompatibleStack; + incompatibleStack = []; + const info = lastSkippedInfo; + lastSkippedInfo = undefined; + if (stack.length === 1) { + reportError(...stack[0]); + if (info) { + // Actually do the last relation error + reportRelationError(/*headMessage*/ undefined, ...info); + } + return; + } + // The first error will be the innermost, while the last will be the outermost - so by popping off the end, + // we can build from left to right + let path = ""; + const secondaryRootErrors: typeof incompatibleStack = []; + while (stack.length) { + const [msg, ...args] = stack.pop()!; + switch (msg.code) { + case Diagnostics.Types_of_property_0_are_incompatible.code: { + // Parenthesize a `new` if there is one + if (path.indexOf("new ") === 0) { + path = `(${path})`; + } + const str = "" + args[0]; + // If leading, just print back the arg (irrespective of if it's a valid identifier) + if (path.length === 0) { + path = `${str}`; + } + // Otherwise write a dotted name if possible + else if (isIdentifierText(str, compilerOptions.target)) { + path = `${path}.${str}`; + } + // Failing that, check if the name is already a computed name + else if (str[0] === "[" && str[str.length - 1] === "]") { + path = `${path}${str}`; + } + // And finally write out a computed name as a last resort + else { + path = `${path}[${str}]`; + } + break; + } + case Diagnostics.Call_signature_return_types_0_and_1_are_incompatible.code: + case Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code: + case Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: + case Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: { + if (path.length === 0) { + // Don't flatten signature compatability errors at the start of a chain - instead prefer + // to unify (the with no arguments bit is excessive for printback) and print them back + let mappedMsg = msg; + if (msg.code === Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = Diagnostics.Call_signature_return_types_0_and_1_are_incompatible; + } + else if (msg.code === Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible; + } + secondaryRootErrors.unshift([mappedMsg, args[0], args[1]]); + } + else { + const prefix = (msg.code === Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code || + msg.code === Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "new " + : ""; + const params = (msg.code === Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code || + msg.code === Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "" + : "..."; + path = `${prefix}${path}(${params})`; + } + break; + } + default: + return Debug.fail(`Unhandled Diagnostic: ${msg.code}`); + } + } + if (path) { + reportError(path[path.length - 1] === ")" + ? Diagnostics.The_types_returned_by_0_are_incompatible_between_these_types + : Diagnostics.The_types_of_0_are_incompatible_between_these_types, + path + ); + } + else { + // Remove the innermost secondary error as it will duplicate the error already reported by `reportRelationError` on entry + secondaryRootErrors.shift(); + } + for (const [msg, ...args] of secondaryRootErrors) { + const originalValue = msg.elidedInCompatabilityPyramid; + msg.elidedInCompatabilityPyramid = false; // Teporarily override elision to ensure error is reported + reportError(msg, ...args); + msg.elidedInCompatabilityPyramid = originalValue; + } + if (info) { + // Actually do the last relation error + reportRelationError(/*headMessage*/ undefined, ...info); + } + } + function reportError(message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number, arg3?: string | number): void { Debug.assert(!!errorNode); + if (incompatibleStack.length) reportIncompatibleStack(); + if (message.elidedInCompatabilityPyramid) return; errorInfo = chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3); } @@ -12733,6 +12929,7 @@ namespace ts { } function reportRelationError(message: DiagnosticMessage | undefined, source: Type, target: Type) { + if (incompatibleStack.length) reportIncompatibleStack(); const [sourceType, targetType] = getTypeNamesForErrorDisplay(source, target); if (target.flags & TypeFlags.TypeParameter && target.immediateBaseConstraint !== undefined && isTypeAssignableTo(source, target.immediateBaseConstraint)) { @@ -12890,7 +13087,7 @@ namespace ts { } let result = Ternary.False; - const saveErrorInfo = errorInfo; + const saveErrorInfo = captureErrorCalculationState(); let isIntersectionConstituent = !!isApparentIntersectionConstituent; // Note that these checks are specifically ordered to produce correct results. In particular, @@ -12940,11 +13137,11 @@ namespace ts { } if (!result && (source.flags & TypeFlags.StructuredOrInstantiable || target.flags & TypeFlags.StructuredOrInstantiable)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } - if (!result && source.flags & TypeFlags.Intersection) { + if (!result && source.flags & (TypeFlags.Intersection | TypeFlags.TypeParameter)) { // The combined constraint of an intersection type is the intersection of the constraints of // the constituents. When an intersection type contains instantiable types with union type // constraints, there are situations where we need to examine the combined constraint. One is @@ -12954,22 +13151,31 @@ namespace ts { // we need to check this constraint against a union on the target side. Also, given a type // variable V constrained to 'string | number', 'V & number' has a combined constraint of // 'string & number | number & number' which reduces to just 'number'. - const constraint = getUnionConstraintOfIntersection(source, !!(target.flags & TypeFlags.Union)); - if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + // This also handles type parameters, as a type parameter with a union constraint compared against a union + // needs to have its constraint hoisted into an intersection with said type parameter, this way + // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) + // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` + const constraint = getEffectiveConstraintOfIntersection(source.flags & TypeFlags.Intersection ? (source).types: [source], !!(target.flags & TypeFlags.Union)); + if (constraint && (source.flags & TypeFlags.Intersection || target.flags & TypeFlags.Union)) { + if (everyType(constraint, c => c !== source)) { // Skip comparison if expansion contains the source itself + // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this + if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { + resetErrorInfo(saveErrorInfo); + } } } } if (!result && reportErrors) { - let maybeSuppress = overrideNextErrorInfo; - overrideNextErrorInfo = undefined; + let maybeSuppress = overrideNextErrorInfo > 0; + if (maybeSuppress) { + overrideNextErrorInfo--; + } if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) { const currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, reportErrors); if (errorInfo !== currentError) { - maybeSuppress = errorInfo; + maybeSuppress = !!errorInfo; } } if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Primitive) { @@ -12989,6 +13195,7 @@ namespace ts { } } if (!headMessage && maybeSuppress) { + lastSkippedInfo = [source, target]; // Used by, eg, missing property checking to replace the top-level message with a more informative one return result; } @@ -13041,6 +13248,11 @@ namespace ts { // JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal. // However, using an object-literal error message will be very confusing to the users so we give different a message. // TODO: Spelling suggestions for excess jsx attributes (needs new diagnostic messages) + if (prop.valueDeclaration && isJsxAttribute(prop.valueDeclaration)) { + // Note that extraneous children (as in `extra`) don't pass this check, + // since `children` is a SyntaxKind.PropertySignature instead of a SyntaxKind.JsxAttribute. + errorNode = prop.valueDeclaration.name; + } reportError(Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(errorTarget)); } else { @@ -13300,18 +13512,6 @@ namespace ts { return result; } - function propagateSidebandVarianceFlags(typeArguments: readonly Type[], variances: VarianceFlags[]) { - for (let i = 0; i < variances.length; i++) { - const v = variances[i]; - if (v & VarianceFlags.Unmeasurable) { - instantiateType(typeArguments[i], reportUnmeasurableMarkers); - } - if (v & VarianceFlags.Unreliable) { - instantiateType(typeArguments[i], reportUnreliableMarkers); - } - } - } - // Determine if possibly recursive types are related. First, check if the result is already available in the global cache. // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are @@ -13322,24 +13522,24 @@ namespace ts { return Ternary.False; } const id = getRelationKey(source, target, relation); - const related = relation.get(id); - if (related !== undefined) { - if (reportErrors && related === RelationComparisonResult.Failed) { + const entry = relation.get(id); + if (entry !== undefined) { + if (reportErrors && entry & RelationComparisonResult.Failed && !(entry & RelationComparisonResult.Reported)) { // We are elaborating errors and the cached result is an unreported failure. The result will be reported // as a failure, and should be updated as a reported failure by the bottom of this function. } else { if (outofbandVarianceMarkerHandler) { // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component - if (source.flags & (TypeFlags.Object | TypeFlags.Conditional) && source.aliasSymbol && - source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { - propagateSidebandVarianceFlags(source.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + const saved = entry & RelationComparisonResult.ReportsMask; + if (saved & RelationComparisonResult.ReportsUnmeasurable) { + instantiateType(source, reportUnmeasurableMarkers); } - if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (source).target === (target).target && length((source).typeArguments)) { - propagateSidebandVarianceFlags((source).typeArguments!, getVariances((source).target)); + if (saved & RelationComparisonResult.ReportsUnreliable) { + instantiateType(source, reportUnreliableMarkers); } } - return related === RelationComparisonResult.Succeeded ? Ternary.True : Ternary.False; + return entry & RelationComparisonResult.Succeeded ? Ternary.True : Ternary.False; } } if (!maybeKeys) { @@ -13368,14 +13568,26 @@ namespace ts { const saveExpandingFlags = expandingFlags; if (!(expandingFlags & ExpandingFlags.Source) && isDeeplyNestedType(source, sourceStack, depth)) expandingFlags |= ExpandingFlags.Source; if (!(expandingFlags & ExpandingFlags.Target) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= ExpandingFlags.Target; + let originalHandler: typeof outofbandVarianceMarkerHandler; + let propagatingVarianceFlags: RelationComparisonResult = 0; + if (outofbandVarianceMarkerHandler) { + originalHandler = outofbandVarianceMarkerHandler; + outofbandVarianceMarkerHandler = onlyUnreliable => { + propagatingVarianceFlags |= onlyUnreliable ? RelationComparisonResult.ReportsUnreliable : RelationComparisonResult.ReportsUnmeasurable; + return originalHandler!(onlyUnreliable); + }; + } const result = expandingFlags !== ExpandingFlags.Both ? structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) : Ternary.Maybe; + if (outofbandVarianceMarkerHandler) { + outofbandVarianceMarkerHandler = originalHandler; + } expandingFlags = saveExpandingFlags; depth--; if (result) { if (result === Ternary.True || depth === 0) { // If result is definitely true, record all maybe keys as having succeeded for (let i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], RelationComparisonResult.Succeeded); + relation.set(maybeKeys[i], RelationComparisonResult.Succeeded | propagatingVarianceFlags); } maybeCount = maybeStart; } @@ -13383,7 +13595,7 @@ namespace ts { else { // A false result goes straight into global cache (when something is false under // assumptions it will also be false without assumptions) - relation.set(id, reportErrors ? RelationComparisonResult.FailedAndReported : RelationComparisonResult.Failed); + relation.set(id, (reportErrors ? RelationComparisonResult.Reported : 0) | RelationComparisonResult.Failed | propagatingVarianceFlags); maybeCount = maybeStart; } return result; @@ -13425,7 +13637,7 @@ namespace ts { let result: Ternary; let originalErrorInfo: DiagnosticMessageChain | undefined; let varianceCheckFailed = false; - const saveErrorInfo = errorInfo; + const saveErrorInfo = captureErrorCalculationState(); // We limit alias variance probing to only object and conditional types since their alias behavior // is more predictable than other, interned types, which may or may not have an alias depending on @@ -13517,7 +13729,7 @@ namespace ts { } } originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -13529,7 +13741,7 @@ namespace ts { result &= isRelatedTo((source).indexType, (target).indexType, reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -13538,25 +13750,25 @@ namespace ts { 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))) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed else if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } } else if (source.flags & TypeFlags.Index) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -13581,7 +13793,7 @@ namespace ts { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -13590,14 +13802,14 @@ namespace ts { const distributiveConstraint = getConstraintOfDistributiveConditionalType(source); if (distributiveConstraint) { if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } const defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { if (result = isRelatedTo(defaultConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -13611,7 +13823,7 @@ namespace ts { if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { if (result = mappedTypeRelatedTo(source, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -13630,7 +13842,7 @@ namespace ts { // type references (which are intended by be compared structurally). Obtain the variance // information for the type parameters and relate the type arguments accordingly. const variances = getVariances((source).target); - const varianceResult = relateVariances((source).typeArguments, (target).typeArguments, variances, isIntersectionConstituent); + const varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -13657,7 +13869,7 @@ namespace ts { // relates to X. Thus, we include intersection types on the source side here. if (source.flags & (TypeFlags.Object | TypeFlags.Intersection) && target.flags & TypeFlags.Object) { // Report structural errors only if we haven't reported any errors yet - const reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; + const reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, isIntersectionConstituent); if (result) { result &= signaturesRelatedTo(source, target, SignatureKind.Call, reportStructuralErrors); @@ -13672,7 +13884,7 @@ namespace ts { } } if (varianceCheckFailed && result) { - errorInfo = originalErrorInfo || errorInfo || saveErrorInfo; // Use variance error (there is no structural one) and return false + errorInfo = originalErrorInfo || errorInfo || saveErrorInfo.errorInfo; // Use variance error (there is no structural one) and return false } else if (result) { return result; @@ -13704,7 +13916,7 @@ namespace ts { // We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially // be assuming identity of the type parameter. originalErrorInfo = undefined; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return undefined; } const allowStructuralFallback = targetTypeArguments && hasCovariantVoidArgument(targetTypeArguments, variances); @@ -13732,7 +13944,7 @@ namespace ts { // comparison unexpectedly succeeds. This can happen when the structural comparison result // is a Ternary.Maybe for example caused by the recursion depth limiter. originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -13966,7 +14178,7 @@ namespace ts { const related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent); if (!related) { if (reportErrors) { - reportError(Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); + reportIncompatibleError(Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } return Ternary.False; } @@ -14008,8 +14220,8 @@ namespace ts { if (length(unmatchedProperty.declarations)) { associateRelatedInfo(createDiagnosticForNode(unmatchedProperty.declarations[0], Diagnostics._0_is_declared_here, propName)); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } else if (tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ false)) { @@ -14019,8 +14231,8 @@ namespace ts { else { reportError(Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, typeToString(source), typeToString(target), map(props, p => symbolToString(p)).join(", ")); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } // ELSE: No array like or unmatched property error - just issue top level error (errorInfo = undefined) @@ -14056,8 +14268,9 @@ namespace ts { } const targetCount = getTypeReferenceArity(target) - 1; const sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + const sourceTypeArguments = getTypeArguments(source); for (let i = targetCount; i < sourceCount; i++) { - const related = isRelatedTo((source).typeArguments![i], targetRestType, reportErrors); + const related = isRelatedTo(sourceTypeArguments[i], targetRestType, reportErrors); if (!related) { if (reportErrors) { reportError(Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); @@ -14071,9 +14284,11 @@ namespace ts { // We only call this for union target types when we're attempting to do excess property checking - in those cases, we want to get _all possible props_ // from the target union, across all members const properties = target.flags & TypeFlags.Union ? getPossiblePropertiesOfUnionType(target as UnionType) : getPropertiesOfType(target); + const numericNamesOnly = isTupleType(source) && isTupleType(target); for (const targetProp of excludeProperties(properties, excludedProperties)) { - if (!(targetProp.flags & SymbolFlags.Prototype)) { - const sourceProp = getPropertyOfType(source, targetProp.escapedName); + const name = targetProp.escapedName; + if (!(targetProp.flags & SymbolFlags.Prototype) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { + const sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { const related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, isIntersectionConstituent); if (!related) { @@ -14143,7 +14358,8 @@ namespace ts { } let result = Ternary.True; - const saveErrorInfo = errorInfo; + const saveErrorInfo = captureErrorCalculationState(); + const incompatibleReporter = kind === SignatureKind.Construct ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; if (getObjectFlags(source) & ObjectFlags.Instantiated && getObjectFlags(target) & ObjectFlags.Instantiated && source.symbol === target.symbol) { // We have instantiations of the same anonymous type (which typically will be the type of a @@ -14151,7 +14367,7 @@ namespace ts { // of the much more expensive N * M comparison matrix we explore below. We erase type parameters // as they are known to always be the same. for (let i = 0; i < targetSignatures.length; i++) { - const related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors); + const related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { return Ternary.False; } @@ -14165,17 +14381,17 @@ namespace ts { // this regardless of the number of signatures, but the potential costs are prohibitive due // to the quadratic nature of the logic below. const eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks; - result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors); + result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors, incompatibleReporter(sourceSignatures[0], targetSignatures[0])); } else { outer: for (const t of targetSignatures) { // Only elaborate errors from the first failure let shouldElaborateErrors = reportErrors; for (const s of sourceSignatures) { - const related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors); + const related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors, incompatibleReporter(s, t)); if (related) { result &= related; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); continue outer; } shouldElaborateErrors = false; @@ -14192,12 +14408,26 @@ namespace ts { return result; } + function reportIncompatibleCallSignatureReturn(siga: Signature, sigb: Signature) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return (source: Type, target: Type) => reportIncompatibleError(Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); + } + return (source: Type, target: Type) => reportIncompatibleError(Diagnostics.Call_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); + } + + function reportIncompatibleConstructSignatureReturn(siga: Signature, sigb: Signature) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return (source: Type, target: Type) => reportIncompatibleError(Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); + } + return (source: Type, target: Type) => reportIncompatibleError(Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); + } + /** * See signatureAssignableTo, compareSignaturesIdentical */ - function signatureRelatedTo(source: Signature, target: Signature, erase: boolean, reportErrors: boolean): Ternary { + function signatureRelatedTo(source: Signature, target: Signature, erase: boolean, reportErrors: boolean, incompatibleReporter: (source: Type, target: Type) => void): Ternary { return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, - CallbackCheck.None, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); + CallbackCheck.None, /*ignoreReturnTypes*/ false, reportErrors, reportError, incompatibleReporter, isRelatedTo); } function signaturesIdenticalTo(source: Type, target: Type, kind: SignatureKind): Ternary { @@ -14468,8 +14698,12 @@ namespace ts { return type.flags & TypeFlags.TypeParameter && !getConstraintOfTypeParameter(type); } + function isNonDeferredTypeReference(type: Type): type is TypeReference { + return !!(getObjectFlags(type) & ObjectFlags.Reference) && !(type).node; + } + function isTypeReferenceWithGenericArguments(type: Type): boolean { - return !!(getObjectFlags(type) & ObjectFlags.Reference) && some((type).typeArguments, t => isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t)); + return isNonDeferredTypeReference(type) && some(getTypeArguments(type), t => isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t)); } /** @@ -14478,7 +14712,7 @@ namespace ts { */ function getTypeReferenceId(type: TypeReference, typeParameters: Type[], depth = 0) { let result = "" + type.target.id; - for (const t of type.typeArguments!) { + for (const t of getTypeArguments(type)) { if (isUnconstrainedTypeParameter(t)) { let index = typeParameters.indexOf(t); if (index < 0) { @@ -14715,16 +14949,18 @@ namespace ts { if (!ignoreReturnTypes) { const sourceTypePredicate = getTypePredicateOfSignature(source); const targetTypePredicate = getTypePredicateOfSignature(target); - result &= sourceTypePredicate !== undefined || targetTypePredicate !== undefined - ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) - // If they're both type predicates their return types will both be `boolean`, so no need to compare those. - : compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + result &= sourceTypePredicate || targetTypePredicate ? + compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) : + compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; } function compareTypePredicatesIdentical(source: TypePredicate | undefined, target: TypePredicate | undefined, compareTypes: (s: Type, t: Type) => Ternary): Ternary { - return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? Ternary.False : compareTypes(source.type, target.type); + return !(source && target && typePredicateKindsMatch(source, target)) ? Ternary.False : + source.type === target.type ? Ternary.True : + source.type && target.type ? compareTypes(source.type, target.type) : + Ternary.False; } function literalTypesWithSameBaseType(types: Type[]): boolean { @@ -14774,7 +15010,7 @@ namespace ts { } function getElementTypeOfArrayType(type: Type): Type | undefined { - return isArrayType(type) && (type as TypeReference).typeArguments ? (type as TypeReference).typeArguments![0] : undefined; + return isArrayType(type) ? getTypeArguments(type as TypeReference)[0] : undefined; } function isArrayLikeType(type: Type): boolean { @@ -14784,7 +15020,7 @@ namespace ts { } function isEmptyArrayLiteralType(type: Type): boolean { - const elementType = isArrayType(type) ? (type).typeArguments![0] : undefined; + const elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined; return elementType === undefinedWideningType || elementType === implicitNeverType; } @@ -14882,7 +15118,7 @@ namespace ts { } function getRestTypeOfTupleType(type: TupleTypeReference) { - return type.target.hasRestElement ? type.typeArguments![type.target.typeParameters!.length - 1] : undefined; + return type.target.hasRestElement ? getTypeArguments(type)[type.target.typeParameters!.length - 1] : undefined; } function getRestArrayTypeOfTupleType(type: TupleTypeReference) { @@ -15171,7 +15407,7 @@ namespace ts { result = getIntersectionType(sameMap((type).types, getWidenedType)); } else if (isArrayType(type) || isTupleType(type)) { - result = createTypeReference((type).target, sameMap((type).typeArguments, getWidenedType)); + result = createTypeReference((type).target, sameMap(getTypeArguments(type), getWidenedType)); } if (result && context === undefined) { type.widened = result; @@ -15208,7 +15444,7 @@ namespace ts { } } if (isArrayType(type) || isTupleType(type)) { - for (const t of (type).typeArguments!) { + for (const t of getTypeArguments(type)) { if (reportWideningErrorsInType(t)) { errorReported = true; } @@ -15332,8 +15568,7 @@ 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)) { + if (sourceTypePredicate && targetTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) { callback(sourceTypePredicate.type, targetTypePredicate.type); } else { @@ -15425,7 +15660,7 @@ namespace ts { function couldContainTypeVariables(type: Type): boolean { const objectFlags = getObjectFlags(type); return !!(type.flags & TypeFlags.Instantiable || - objectFlags & ObjectFlags.Reference && forEach((type).typeArguments, couldContainTypeVariables) || + objectFlags & ObjectFlags.Reference && forEach(getTypeArguments(type), couldContainTypeVariables) || objectFlags & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) && type.symbol.declarations || objectFlags & ObjectFlags.Mapped || type.flags & TypeFlags.UnionOrIntersection && !(type.flags & TypeFlags.EnumLiteral) && couldUnionOrIntersectionContainTypeVariables(type)); @@ -15501,10 +15736,10 @@ namespace ts { // For arrays and tuples we infer new arrays and tuples where the reverse mapping has been // applied to the element type(s). if (isArrayType(source)) { - return createArrayType(inferReverseMappedType((source).typeArguments![0], target, constraint), isReadonlyArrayType(source)); + return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source)); } if (isTupleType(source)) { - const elementTypes = map(source.typeArguments || emptyArray, t => inferReverseMappedType(t, target, constraint)); + const elementTypes = map(getTypeArguments(source), t => inferReverseMappedType(t, target, constraint)); const minLength = getMappedTypeModifiers(target) & MappedTypeModifiers.IncludeOptional ? getTypeReferenceArity(source) - (source.target.hasRestElement ? 1 : 0) : source.target.minLength; return createTupleType(elementTypes, minLength, source.target.hasRestElement, source.target.readonly, source.target.associatedNames); @@ -15724,7 +15959,7 @@ namespace ts { if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && ( (source).target === (target).target || isArrayType(source) && isArrayType(target))) { // If source and target are references to the same generic type, infer from type arguments - inferFromTypeArguments((source).typeArguments || emptyArray, (target).typeArguments || emptyArray, getVariances((source).target)); + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances((source).target)); } else if (source.flags & TypeFlags.Index && target.flags & TypeFlags.Index) { contravariant = !contravariant; @@ -16033,10 +16268,10 @@ namespace ts { const targetRestType = getRestTypeOfTupleType(target); const fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; for (let i = 0; i < fixedLength; i++) { - inferFromTypes(i < sourceLength ? (source).typeArguments![i] : sourceRestType!, target.typeArguments![i]); + inferFromTypes(i < sourceLength ? getTypeArguments(source)[i] : sourceRestType!, getTypeArguments(target)[i]); } if (targetRestType) { - const types = fixedLength < sourceLength ? (source).typeArguments!.slice(fixedLength, sourceLength) : []; + const types = fixedLength < sourceLength ? getTypeArguments(source).slice(fixedLength, sourceLength) : []; if (sourceRestType) { types.push(sourceRestType); } @@ -16949,23 +17184,64 @@ namespace ts { return isLengthPushOrUnshift || isElementAssignment; } - function maybeTypePredicateCall(node: CallExpression) { - const links = getNodeLinks(node); - if (links.maybeTypePredicate === undefined) { - links.maybeTypePredicate = getMaybeTypePredicate(node); - } - return links.maybeTypePredicate; + function isDeclarationWithExplicitTypeAnnotation(declaration: Declaration | undefined) { + return !!(declaration && ( + declaration.kind === SyntaxKind.VariableDeclaration || declaration.kind === SyntaxKind.Parameter || + declaration.kind === SyntaxKind.PropertyDeclaration || declaration.kind === SyntaxKind.PropertySignature) && + getEffectiveTypeAnnotationNode(declaration as VariableDeclaration | ParameterDeclaration | PropertyDeclaration | PropertySignature)); } - function getMaybeTypePredicate(node: CallExpression) { - if (node.expression.kind !== SyntaxKind.SuperKeyword) { - const funcType = checkNonNullExpression(node.expression); - if (funcType !== silentNeverType) { - const apparentType = getApparentType(funcType); - return apparentType !== errorType && some(getSignaturesOfType(apparentType, SignatureKind.Call), signatureHasTypePredicate); + function getExplicitTypeOfSymbol(symbol: Symbol) { + return symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.ValueModule) || + symbol.flags & (SymbolFlags.Variable | SymbolFlags.Property) && isDeclarationWithExplicitTypeAnnotation(symbol.valueDeclaration) ? + getTypeOfSymbol(symbol) : undefined; + } + + // We require the dotted function name in an assertion expression to be comprised of identifiers + // that reference function, method, class or value module symbols; or variable, property or + // parameter symbols with declarations that have explicit type annotations. Such references are + // resolvable with no possibility of triggering circularities in control flow analysis. + function getTypeOfDottedName(node: Expression): Type | undefined { + if (!(node.flags & NodeFlags.InWithStatement)) { + switch (node.kind) { + case SyntaxKind.Identifier: + const symbol = getResolvedSymbol(node); + return getExplicitTypeOfSymbol(symbol.flags & SymbolFlags.Alias ? resolveAlias(symbol) : symbol); + case SyntaxKind.ThisKeyword: + return getExplicitThisType(node); + case SyntaxKind.PropertyAccessExpression: + const type = getTypeOfDottedName((node).expression); + const prop = type && getPropertyOfType(type, (node).name.escapedText); + return prop && getExplicitTypeOfSymbol(prop); + case SyntaxKind.ParenthesizedExpression: + return getTypeOfDottedName((node).expression); } } - return false; + } + + function getEffectsSignature(node: CallExpression) { + const links = getNodeLinks(node); + let signature = links.effectsSignature; + if (signature === undefined) { + // A call expression parented by an expression statement is a potential assertion. Other call + // expressions are potential type predicate function calls. In order to avoid triggering + // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call + // target expression of an assertion. + const funcType = node.parent.kind === SyntaxKind.ExpressionStatement ? getTypeOfDottedName(node.expression) : + node.expression.kind !== SyntaxKind.SuperKeyword ? checkNonNullExpression(node.expression) : + undefined; + const signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, SignatureKind.Call); + const candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : + some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : + undefined; + signature = links.effectsSignature = candidate && hasTypePredicateOrNeverReturnType(candidate) ? candidate : unknownSignature; + } + return signature === unknownSignature ? undefined : signature; + } + + function hasTypePredicateOrNeverReturnType(signature: Signature) { + return !!(getTypePredicateOfSignature(signature) || + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & TypeFlags.Never); } function reportFlowControlError(node: Node) { @@ -16975,6 +17251,71 @@ namespace ts { diagnostics.add(createFileDiagnostic(sourceFile, span.start, span.length, Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)); } + function isReachableFlowNode(flow: FlowNode) { + const result = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + lastFlowNode = flow; + lastFlowNodeReachable = result; + return result; + } + + function isUnlockedReachableFlowNode(flow: FlowNode) { + return !(flow.flags & FlowFlags.PreFinally && (flow).lock.locked) && isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + } + + function isReachableFlowNodeWorker(flow: FlowNode, noCacheCheck: boolean): boolean { + while (true) { + if (flow === lastFlowNode) { + return lastFlowNodeReachable; + } + const flags = flow.flags; + if (flags & FlowFlags.Shared) { + if (!noCacheCheck) { + const id = getFlowNodeId(flow); + const reachable = flowNodeReachable[id]; + return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ true)); + } + noCacheCheck = false; + } + if (flags & (FlowFlags.Assignment | FlowFlags.Condition | FlowFlags.ArrayMutation | FlowFlags.PreFinally)) { + flow = (flow).antecedent; + } + else if (flags & FlowFlags.Call) { + const signature = getEffectsSignature((flow).node); + if (signature && getReturnTypeOfSignature(signature).flags & TypeFlags.Never) { + return false; + } + flow = (flow).antecedent; + } + else if (flags & FlowFlags.BranchLabel) { + // A branching point is reachable if any branch is reachable. + return some((flow).antecedents, isUnlockedReachableFlowNode); + } + else if (flags & FlowFlags.LoopLabel) { + // A loop is reachable if the control flow path that leads to the top is reachable. + flow = (flow).antecedents![0]; + } + else if (flags & FlowFlags.SwitchClause) { + // The control flow path representing an unmatched value in a switch statement with + // no default clause is unreachable if the switch statement is exhaustive. + if ((flow).clauseStart === (flow).clauseEnd && isExhaustiveSwitchStatement((flow).switchStatement)) { + return false; + } + flow = (flow).antecedent; + } + else if (flags & FlowFlags.AfterFinally) { + // Cache is unreliable once we start locking nodes + lastFlowNode = undefined; + (flow).locked = true; + const result = isReachableFlowNodeWorker((flow).antecedent, /*skipCacheCheck*/ false); + (flow).locked = false; + return result; + } + else { + return !(flags & FlowFlags.Unreachable); + } + } + } + function getFlowTypeOfReference(reference: Node, declaredType: Type, initialType = declaredType, flowContainer?: Node, couldBeUninitialized?: boolean) { let key: string | undefined; let keySet = false; @@ -16994,7 +17335,7 @@ namespace ts { // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. const resultType = getObjectFlags(evolvedType) & ObjectFlags.EvolvingArray && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === SyntaxKind.NonNullExpression && getTypeWithFacts(resultType, TypeFacts.NEUndefinedOrNull).flags & TypeFlags.Never) { + if (resultType === unreachableNeverType|| reference.parent && reference.parent.kind === SyntaxKind.NonNullExpression && getTypeWithFacts(resultType, TypeFacts.NEUndefinedOrNull).flags & TypeFlags.Never) { return declaredType; } return resultType; @@ -17049,6 +17390,13 @@ namespace ts { continue; } } + else if (flags & FlowFlags.Call) { + type = getTypeAtFlowCall(flow); + if (!type) { + flow = (flow).antecedent; + continue; + } + } else if (flags & FlowFlags.Condition) { type = getTypeAtFlowCondition(flow); } @@ -17073,7 +17421,7 @@ namespace ts { } else if (flags & FlowFlags.Start) { // Check if we should continue with the control flow of the containing function. - const container = (flow).container; + const container = (flow).node; if (container && container !== flowContainer && reference.kind !== SyntaxKind.PropertyAccessExpression && reference.kind !== SyntaxKind.ElementAccessExpression && @@ -17126,6 +17474,9 @@ namespace ts { // Assignments only narrow the computed type if the declared type is a union type. Thus, we // only need to evaluate the assigned type if the declared type is a union type. if (isMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } if (getAssignmentTargetKind(node) === AssignmentKind.Compound) { const flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); @@ -17147,6 +17498,9 @@ namespace ts { // reference 'x.y.z', we may be at an assignment to 'x.y' or 'x'. In that case, // return the declared type. if (containsMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } // A matching dotted name might also be an expando property on a function *expression*, // in which case we continue control flow analysis back to the function's declaration if (isVariableDeclaration(node) && (isInJSFile(node) || isVarConst(node))) { @@ -17165,6 +17519,38 @@ namespace ts { return undefined; } + function narrowTypeByAssertion(type: Type, expr: Expression): Type { + const node = skipParentheses(expr); + if (node.kind === SyntaxKind.BinaryExpression) { + if ((node).operatorToken.kind === SyntaxKind.AmpersandAmpersandToken) { + return narrowTypeByAssertion(narrowTypeByAssertion(type, (node).left), (node).right); + } + if ((node).operatorToken.kind === SyntaxKind.BarBarToken) { + return getUnionType([narrowTypeByAssertion(type, (node).left), narrowTypeByAssertion(type, (node).right)]); + } + } + return narrowType(type, node, /*assumeTrue*/ true); + } + + function getTypeAtFlowCall(flow: FlowCall): FlowType | undefined { + const signature = getEffectsSignature(flow.node); + if (signature) { + const predicate = getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === TypePredicateKind.AssertsThis || predicate.kind === TypePredicateKind.AssertsIdentifier)) { + const flowType = getTypeAtFlowNode(flow.antecedent); + const type = getTypeFromFlowType(flowType); + const narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : + predicate.kind === TypePredicateKind.AssertsIdentifier ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : + type; + return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); + } + if (getReturnTypeOfSignature(signature).flags & TypeFlags.Never) { + return unreachableNeverType; + } + } + return undefined; + } + function getTypeAtFlowArrayMutation(flow: FlowArrayMutation): FlowType | undefined { if (declaredType === autoType || declaredType === autoArrayType) { const node = flow.node; @@ -17211,7 +17597,7 @@ namespace ts { // *only* place a silent never type is ever generated. const assumeTrue = (flow.flags & FlowFlags.TrueCondition) !== 0; const nonEvolvingType = finalizeEvolvingArrayType(type); - const narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + const narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { return flowType; } @@ -17239,6 +17625,9 @@ namespace ts { else if (containsMatchingReferenceDiscriminant(reference, expr)) { type = declaredType; } + else if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return unreachableNeverType; + } return createFlowType(type, isIncomplete(flowType)); } @@ -17755,24 +18144,25 @@ namespace ts { getIntersectionType([type, candidate]); } - function narrowTypeByTypePredicate(type: Type, callExpression: CallExpression, assumeTrue: boolean): Type { - if (!hasMatchingArgument(callExpression, reference) || !maybeTypePredicateCall(callExpression)) { - return type; - } - const signature = getResolvedSignature(callExpression); - const predicate = getTypePredicateOfSignature(signature); - if (!predicate) { - return type; + function narrowTypeByCallExpression(type: Type, callExpression: CallExpression, assumeTrue: boolean): Type { + if (hasMatchingArgument(callExpression, reference)) { + const signature = getEffectsSignature(callExpression); + const predicate = signature && getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === TypePredicateKind.This || predicate.kind === TypePredicateKind.Identifier)) { + return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); + } } + return type; + } + function narrowTypeByTypePredicate(type: Type, predicate: TypePredicate, callExpression: CallExpression, assumeTrue: boolean): Type { // Don't narrow from 'any' if the predicate type is exactly 'Object' or 'Function' if (isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType)) { return type; } - - if (isIdentifierTypePredicate(predicate)) { + if (predicate.kind === TypePredicateKind.Identifier || predicate.kind === TypePredicateKind.AssertsIdentifier) { const predicateArgument = callExpression.arguments[predicate.parameterIndex]; - if (predicateArgument) { + if (predicateArgument && predicate.type) { if (isMatchingReference(reference, predicateArgument)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); } @@ -17783,7 +18173,7 @@ namespace ts { } else { const invokedExpression = skipParentheses(callExpression.expression); - if (isAccessExpression(invokedExpression)) { + if (isAccessExpression(invokedExpression) && predicate.type) { const possibleReference = skipParentheses(invokedExpression.expression); if (isMatchingReference(reference, possibleReference)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); @@ -17807,7 +18197,7 @@ namespace ts { case SyntaxKind.ElementAccessExpression: return narrowTypeByTruthiness(type, expr, assumeTrue); case SyntaxKind.CallExpression: - return narrowTypeByTypePredicate(type, expr, assumeTrue); + return narrowTypeByCallExpression(type, expr, assumeTrue); case SyntaxKind.ParenthesizedExpression: return narrowType(type, (expr).expression, assumeTrue); case SyntaxKind.BinaryExpression: @@ -18403,6 +18793,20 @@ namespace ts { } } + function getExplicitThisType(node: Expression) { + const container = getThisContainer(node, /*includeArrowFunctions*/ false); + if (isFunctionLike(container)) { + const signature = getSignatureFromDeclaration(container); + if (signature.thisParameter) { + return getExplicitTypeOfSymbol(signature.thisParameter); + } + } + if (isClassLike(container.parent)) { + const symbol = getSymbolOfNode(container.parent); + return hasModifier(container, ModifierFlags.Static) ? getTypeOfSymbol(symbol) : (getDeclaredTypeOfSymbol(symbol) as InterfaceType).thisType!; + } + } + function getClassNameFromPrototypeMethod(container: Node) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } if (container.kind === SyntaxKind.FunctionExpression && @@ -18686,7 +19090,7 @@ namespace ts { } function getThisTypeArgument(type: Type): Type | undefined { - return getObjectFlags(type) & ObjectFlags.Reference && (type).target === globalThisType ? (type).typeArguments![0] : undefined; + return getObjectFlags(type) & ObjectFlags.Reference && (type).target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type: Type): Type | undefined { @@ -21739,7 +22143,7 @@ namespace ts { const spreadArgument = args[length - 1]; const type = flowLoopCount ? checkExpression(spreadArgument.expression) : checkExpressionCached(spreadArgument.expression); if (isTupleType(type)) { - const typeArguments = (type).typeArguments || emptyArray; + const typeArguments = getTypeArguments(type); const restIndex = type.target.hasRestElement ? typeArguments.length - 1 : -1; const syntheticArgs = map(typeArguments, (t, i) => createSyntheticExpression(spreadArgument, t, /*isSpread*/ i === restIndex)); return concatenate(args.slice(0, length - 1), syntheticArgs); @@ -23279,7 +23683,7 @@ namespace ts { // otherwise would return the type 'undefined'). const restType = getTypeOfSymbol(signature.parameters[paramCount]); const index = pos - paramCount; - if (!isTupleType(restType) || restType.target.hasRestElement || index < (restType.typeArguments || emptyArray).length) { + if (!isTupleType(restType) || restType.target.hasRestElement || index < getTypeArguments(restType).length) { return getIndexedAccessType(restType, getLiteralType(index)); } } @@ -23313,7 +23717,7 @@ namespace ts { if (signature.hasRestParameter) { const restType = getTypeOfSymbol(signature.parameters[length - 1]); if (isTupleType(restType)) { - return length + (restType.typeArguments || emptyArray).length - 1; + return length + getTypeArguments(restType).length - 1; } } return length; @@ -23693,9 +24097,11 @@ namespace ts { } function isExhaustiveSwitchStatement(node: SwitchStatement): boolean { - if (!node.possiblyExhaustive) { - return false; - } + const links = getNodeLinks(node); + return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); + } + + function computeExhaustiveSwitchStatement(node: SwitchStatement): boolean { if (node.expression.kind === SyntaxKind.TypeOfExpression) { const operandType = getTypeOfExpression((node.expression as TypeOfExpression).expression); // This cast is safe because the switch is possibly exhaustive and does not contain a default case, so there can be no undefined. @@ -23717,14 +24123,7 @@ namespace ts { } function functionHasImplicitReturn(func: FunctionLikeDeclaration) { - if (!(func.flags & NodeFlags.HasImplicitReturn)) { - return false; - } - - if (some((func.body).statements, statement => statement.kind === SyntaxKind.SwitchStatement && isExhaustiveSwitchStatement(statement))) { - return false; - } - return true; + return func.endFlowNode && isReachableFlowNode(func.endFlowNode); } /** NOTE: Return value of `[]` means a different thing than `undefined`. `[]` means func returns `void`, `undefined` means it returns `never`. */ @@ -25056,7 +25455,7 @@ namespace ts { function padTupleType(type: TupleTypeReference, pattern: ArrayBindingPattern) { const patternElements = pattern.elements; const arity = getTypeReferenceArity(type); - const elementTypes = arity ? type.typeArguments!.slice() : []; + const elementTypes = arity ? getTypeArguments(type).slice() : []; for (let i = arity; i < patternElements.length; i++) { const e = patternElements[i]; if (i < patternElements.length - 1 || !(e.kind === SyntaxKind.BindingElement && e.dotDotDotToken)) { @@ -25550,7 +25949,7 @@ namespace ts { checkSourceElement(node.type); const { parameterName } = node; - if (isThisTypePredicate(typePredicate)) { + if (typePredicate.kind === TypePredicateKind.This || typePredicate.kind === TypePredicateKind.AssertsThis) { getTypeFromThisTypeNode(parameterName as ThisTypeNode); } else { @@ -25559,12 +25958,14 @@ namespace ts { 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, - getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), - node.type, - /*headMessage*/ undefined, - leadingError); + if (typePredicate.type) { + const leadingError = () => chainDiagnosticMessages(/*details*/ undefined, Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); + checkTypeAssignableTo(typePredicate.type, + getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), + node.type, + /*headMessage*/ undefined, + leadingError); + } } } else if (parameterName) { @@ -26078,16 +26479,13 @@ namespace ts { if (node.kind === SyntaxKind.TypeReference && node.typeName.jsdocDotPos !== undefined && !isInJSFile(node) && !isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } + forEach(node.typeArguments, checkSourceElement); const type = getTypeFromTypeReference(node); if (type !== errorType) { - if (node.typeArguments) { - // Do type argument local checks only if referenced type is successfully resolved - forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - const typeParameters = getTypeParametersForTypeReference(node); - if (typeParameters) { - checkTypeArgumentConstraints(node, typeParameters); - } + if (node.typeArguments && produceDiagnostics) { + const typeParameters = getTypeParametersForTypeReference(node); + if (typeParameters) { + checkTypeArgumentConstraints(node, typeParameters); } } if (type.flags & TypeFlags.Enum && getNodeLinks(node).resolvedSymbol!.flags & SymbolFlags.EnumMember) { @@ -26132,7 +26530,7 @@ namespace ts { grammarErrorOnNode(e, Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; } - if (!isArrayType(getTypeFromTypeNode(e))) { + if (!isArrayType(getTypeFromTypeNode((e).type))) { error(e, Diagnostics.A_rest_element_type_must_be_an_array_type); } } @@ -26626,7 +27024,7 @@ namespace ts { } if (isReferenceToType(promise, getGlobalPromiseType(/*reportErrors*/ false))) { - return typeAsPromise.promisedTypeOfPromise = (promise).typeArguments![0]; + return typeAsPromise.promisedTypeOfPromise = getTypeArguments(promise)[0]; } const thenFunction = getTypeOfPropertyOfType(promise, "then" as __String)!; // TODO: GH#18217 @@ -27978,7 +28376,8 @@ namespace ts { // Grammar checking checkGrammarStatementInAmbientContext(node); - checkTruthinessExpression(node.expression); + const type = checkTruthinessExpression(node.expression); + checkTestingKnownTruthyCallableType(node, type); checkSourceElement(node.thenStatement); if (node.thenStatement.kind === SyntaxKind.EmptyStatement) { @@ -27988,6 +28387,57 @@ namespace ts { checkSourceElement(node.elseStatement); } + function checkTestingKnownTruthyCallableType(ifStatement: IfStatement, type: Type) { + if (!strictNullChecks) { + return; + } + + const testedNode = isIdentifier(ifStatement.expression) + ? ifStatement.expression + : isPropertyAccessExpression(ifStatement.expression) + ? ifStatement.expression.name + : undefined; + + if (!testedNode) { + return; + } + + const possiblyFalsy = getFalsyFlags(type); + if (possiblyFalsy) { + return; + } + + // While it technically should be invalid for any known-truthy value + // to be tested, we de-scope to functions unrefenced in the block as a + // heuristic to identify the most common bugs. There are too many + // false positives for values sourced from type definitions without + // strictNullChecks otherwise. + const callSignatures = getSignaturesOfType(type, SignatureKind.Call); + if (callSignatures.length === 0) { + return; + } + + const testedFunctionSymbol = getSymbolAtLocation(testedNode); + if (!testedFunctionSymbol) { + return; + } + + const functionIsUsedInBody = forEachChild(ifStatement.thenStatement, function check(childNode): boolean | undefined { + if (isIdentifier(childNode)) { + const childSymbol = getSymbolAtLocation(childNode); + if (childSymbol && childSymbol.id === testedFunctionSymbol.id) { + return true; + } + } + + return forEachChild(childNode, check); + }); + + if (!functionIsUsedInBody) { + error(ifStatement.expression, Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + } + } + function checkDoStatement(node: DoStatement) { // Grammar checking checkGrammarStatementInAmbientContext(node); @@ -28519,7 +28969,7 @@ namespace ts { let globalType: Type; if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(/*reportErrors*/ false)) || isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false))) { - const [yieldType] = (type as GenericType).typeArguments!; + const [yieldType] = getTypeArguments(type as GenericType); // The "return" and "next" types of `Iterable` and `IterableIterator` are defined by the // iteration types of their `[Symbol.iterator]()` method. The same is true for their async cousins. // While we define these as `any` and `undefined` in our libs by default, a custom lib *could* use @@ -28532,7 +28982,7 @@ namespace ts { // just grab its related type arguments: // - `Generator` or `AsyncGenerator` if (isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - const [yieldType, returnType, nextType] = (type as GenericType).typeArguments!; + const [yieldType, returnType, nextType] = getTypeArguments(type as GenericType); return (type as IterableOrIteratorType)[resolver.iterableCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -28620,7 +29070,7 @@ namespace ts { // - `Generator` or `AsyncGenerator` const globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false); if (isReferenceToType(type, globalType)) { - const [yieldType] = (type as GenericType).typeArguments!; + const [yieldType] = getTypeArguments(type as GenericType); // The "return" and "next" types of `IterableIterator` and `AsyncIterableIterator` are defined by the // iteration types of their `next`, `return`, and `throw` methods. While we define these as `any` // and `undefined` in our libs by default, a custom lib *could* use different definitions. @@ -28632,7 +29082,7 @@ namespace ts { } if (isReferenceToType(type, resolver.getGlobalIteratorType(/*reportErrors*/ false)) || isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - const [yieldType, returnType, nextType] = (type as GenericType).typeArguments!; + const [yieldType, returnType, nextType] = getTypeArguments(type as GenericType); return (type as IterableOrIteratorType)[resolver.iteratorCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -28674,11 +29124,11 @@ namespace ts { // As an optimization, if the type is an instantiation of one of the global `IteratorYieldResult` // or `IteratorReturnResult` types, then just grab its type argument. if (isReferenceToType(type, getGlobalIteratorYieldResultType(/*reportErrors*/ false))) { - const yieldType = (type as GenericType).typeArguments![0]; + const yieldType = getTypeArguments(type as GenericType)[0]; return (type as IterableOrIteratorType).iterationTypesOfIteratorResult = createIterationTypes(yieldType, /*returnType*/ undefined, /*nextType*/ undefined); } if (isReferenceToType(type, getGlobalIteratorReturnResultType(/*reportErrors*/ false))) { - const returnType = (type as GenericType).typeArguments![0]; + const returnType = getTypeArguments(type as GenericType)[0]; return (type as IterableOrIteratorType).iterationTypesOfIteratorResult = createIterationTypes(/*yieldType*/ undefined, returnType, /*nextType*/ undefined); } @@ -29314,6 +29764,7 @@ namespace ts { const baseTypeNode = getEffectiveBaseTypeNode(node); if (baseTypeNode) { + forEach(baseTypeNode.typeArguments, checkSourceElement); if (languageVersion < ScriptTarget.ES2015) { checkExternalEmitHelpers(baseTypeNode.parent, ExternalEmitHelpers.Extends); } @@ -29353,12 +29804,9 @@ namespace ts { if (!(staticBaseType.symbol && staticBaseType.symbol.flags & SymbolFlags.Class) && !(baseConstructorType.flags & TypeFlags.TypeVariable)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify - // that all instantiated base constructor signatures return the same type. We can simply compare the type - // references (as opposed to checking the structure of the types) because elsewhere we have already checked - // that the base type is a class or interface type (and not, for example, an anonymous object type). - // (Javascript constructor functions have this property trivially true since their return type is ignored.) + // that all instantiated base constructor signatures return the same type. const constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); - if (forEach(constructors, sig => !isJSConstructor(sig.declaration) && getReturnTypeOfSignature(sig) !== baseType)) { + if (forEach(constructors, sig => !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType))) { error(baseTypeNode.expression, Diagnostics.Base_constructors_must_all_have_the_same_return_type); } } @@ -30430,6 +30878,9 @@ namespace ts { cancellationToken.throwIfCancellationRequested(); } } + if (kind >= SyntaxKind.FirstStatement && kind <= SyntaxKind.LastStatement && node.flowNode && !isReachableFlowNode(node.flowNode)) { + errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, Diagnostics.Unreachable_code_detected); + } switch (kind) { case SyntaxKind.TypeParameter: @@ -30731,7 +31182,7 @@ namespace ts { function checkSourceFileWorker(node: SourceFile) { const links = getNodeLinks(node); if (!(links.flags & NodeCheckFlags.TypeChecked)) { - if (skipTypeChecking(node, compilerOptions)) { + if (skipTypeChecking(node, compilerOptions, host)) { return; } @@ -31428,8 +31879,7 @@ namespace ts { const nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, TypeFlags.ESSymbolLike) ? nameType : stringType; default: - Debug.fail("Unsupported property name."); - return errorType; + return Debug.fail("Unsupported property name."); } } @@ -32998,6 +33448,7 @@ namespace ts { // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion for (const mod of prop.modifiers!) { // TODO: GH#19955 if (mod.kind !== SyntaxKind.AsyncKeyword || prop.kind !== SyntaxKind.MethodDeclaration) { grammarErrorOnNode(mod, Diagnostics._0_modifier_cannot_be_used_here, getTextOfNode(mod)); diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 009c04fbb8c..fd0d428d54b 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -772,6 +772,12 @@ namespace ts { category: Diagnostics.Advanced_Options, description: Diagnostics.Disable_size_limitations_on_JavaScript_projects }, + { + name: "disableSourceOfProjectReferenceRedirect", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects + }, { name: "noImplicitUseStrict", type: "boolean", diff --git a/src/compiler/core.ts b/src/compiler/core.ts index d930bee4711..0a3f0ff6749 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1654,7 +1654,7 @@ namespace ts { */ export function compose(...args: ((t: T) => T)[]): (t: T) => T; export function compose(a: (t: T) => T, b: (t: T) => T, c: (t: T) => T, d: (t: T) => T, e: (t: T) => T): (t: T) => T { - if (e) { + if (!!e) { const args: ((t: T) => T)[] = []; for (let i = 0; i < arguments.length; i++) { args[i] = arguments[i]; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 44bba361bbc..87052c4e7cd 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1040,6 +1040,35 @@ "code": 1357 }, + "The types of '{0}' are incompatible between these types.": { + "category": "Error", + "code": 2200 + }, + "The types returned by '{0}' are incompatible between these types.": { + "category": "Error", + "code": 2201 + }, + "Call signature return types '{0}' and '{1}' are incompatible.": { + "category": "Error", + "code": 2202, + "elidedInCompatabilityPyramid": true + }, + "Construct signature return types '{0}' and '{1}' are incompatible.": { + "category": "Error", + "code": 2203, + "elidedInCompatabilityPyramid": true + }, + "Call signatures with no arguments have incompatible return types '{0}' and '{1}'.": { + "category": "Error", + "code": 2204, + "elidedInCompatabilityPyramid": true + }, + "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.": { + "category": "Error", + "code": 2205, + "elidedInCompatabilityPyramid": true + }, + "Duplicate identifier '{0}'.": { "category": "Error", "code": 2300 @@ -2693,7 +2722,10 @@ "category": "Error", "code": 2773 }, - + "This condition will always return true since the function is always defined. Did you mean to call it instead?": { + "category": "Error", + "code": 2774 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 @@ -4007,6 +4039,10 @@ "category": "Message", "code": 6220 }, + "Disable use of source files instead of declaration files from referenced projects.": { + "category": "Message", + "code": 6221 + }, "Projects to reference": { "category": "Message", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 7bad8359b26..2ed08f29e21 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1946,11 +1946,17 @@ namespace ts { // function emitTypePredicate(node: TypePredicateNode) { + if (node.assertsModifier) { + emit(node.assertsModifier); + writeSpace(); + } emit(node.parameterName); - writeSpace(); - writeKeyword("is"); - writeSpace(); - emit(node.type); + if (node.type) { + writeSpace(); + writeKeyword("is"); + writeSpace(); + emit(node.type); + } } function emitTypeReference(node: TypeReferenceNode) { diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 033299cd587..bd2dcbee6f1 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -669,16 +669,26 @@ namespace ts { } export function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode) { + return createTypePredicateNodeWithModifier(/*assertsModifier*/ undefined, parameterName, type); + } + + export function createTypePredicateNodeWithModifier(assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode | string, type: TypeNode | undefined) { const node = createSynthesizedNode(SyntaxKind.TypePredicate) as TypePredicateNode; + node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; return node; } export function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode) { - return node.parameterName !== parameterName + return updateTypePredicateNodeWithModifier(node, node.assertsModifier, parameterName, type); + } + + export function updateTypePredicateNodeWithModifier(node: TypePredicateNode, assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode, type: TypeNode | undefined) { + return node.assertsModifier !== assertsModifier + || node.parameterName !== parameterName || node.type !== type - ? updateNode(createTypePredicateNode(parameterName, type), node) + ? updateNode(createTypePredicateNodeWithModifier(assertsModifier, parameterName, type), node) : node; } diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index cd566c0e6e8..fbb832400c2 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -186,6 +186,18 @@ namespace ts.moduleSpecifiers { return result; } + function numberOfDirectorySeparators(str: string) { + const match = str.match(/\//g); + return match ? match.length : 0; + } + + function comparePathsByNumberOfDirectrorySeparators(a: string, b: string) { + return compareValues( + numberOfDirectorySeparators(a), + numberOfDirectorySeparators(b) + ); + } + /** * Looks for existing imports that use symlinks to this module. * Symlinks will be returned first so they are preferred over the real path. @@ -214,7 +226,32 @@ namespace ts.moduleSpecifiers { } }); result.push(...targets); - return result; + if (result.length < 2) return result; + + // Sort by paths closest to importing file Name directory + const allFileNames = arrayToMap(result, identity, getCanonicalFileName); + const sortedPaths: string[] = []; + for ( + let directory = getDirectoryPath(toPath(importingFileName, cwd, getCanonicalFileName)); + allFileNames.size !== 0; + directory = getDirectoryPath(directory) + ) { + const directoryStart = ensureTrailingDirectorySeparator(directory); + let pathsInDirectory: string[] | undefined; + allFileNames.forEach((canonicalFileName, fileName) => { + if (startsWith(canonicalFileName, directoryStart)) { + (pathsInDirectory || (pathsInDirectory = [])).push(fileName); + allFileNames.delete(fileName); + } + }); + if (pathsInDirectory) { + if (pathsInDirectory.length > 1) { + pathsInDirectory.sort(comparePathsByNumberOfDirectrorySeparators); + } + sortedPaths.push(...pathsInDirectory); + } + } + return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol: Symbol): string | undefined { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f437ca697a8..edaa7ebeaeb 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -165,7 +165,8 @@ namespace ts { return visitNode(cbNode, (node).typeName) || visitNodes(cbNode, cbNodes, (node).typeArguments); case SyntaxKind.TypePredicate: - return visitNode(cbNode, (node).parameterName) || + return visitNode(cbNode, (node).assertsModifier) || + visitNode(cbNode, (node).parameterName) || visitNode(cbNode, (node).type); case SyntaxKind.TypeQuery: return visitNode(cbNode, (node).exprName); @@ -3041,6 +3042,8 @@ namespace ts { return parseParenthesizedType(); case SyntaxKind.ImportKeyword: return parseImportType(); + case SyntaxKind.AssertsKeyword: + return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); default: return parseTypeReference(); } @@ -3081,6 +3084,7 @@ namespace ts { case SyntaxKind.DotDotDotToken: case SyntaxKind.InferKeyword: case SyntaxKind.ImportKeyword: + case SyntaxKind.AssertsKeyword: return true; case SyntaxKind.FunctionKeyword: return !inStartOfParameter; @@ -3257,6 +3261,7 @@ namespace ts { const type = parseType(); if (typePredicateVariable) { const node = createNode(SyntaxKind.TypePredicate, typePredicateVariable.pos); + node.assertsModifier = undefined; node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -3274,6 +3279,14 @@ namespace ts { } } + function parseAssertsTypePredicate(): TypeNode { + const node = createNode(SyntaxKind.TypePredicate); + node.assertsModifier = parseExpectedToken(SyntaxKind.AssertsKeyword); + node.parameterName = token() === SyntaxKind.ThisKeyword ? parseThisTypeNode() : parseIdentifier(); + node.type = parseOptional(SyntaxKind.IsKeyword) ? parseType() : undefined; + return finishNode(node); + } + function parseType(): TypeNode { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 23a3e660c82..04c2c8d2c77 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -817,6 +817,8 @@ namespace ts { let resolvedProjectReferences: readonly (ResolvedProjectReference | undefined)[] | undefined; let projectReferenceRedirects: Map | undefined; let mapFromFileToProjectReferenceRedirects: Map | undefined; + let mapFromToProjectReferenceRedirectSource: Map | undefined; + const useSourceOfProjectReferenceRedirect = !!host.useSourceOfProjectReferenceRedirect && host.useSourceOfProjectReferenceRedirect(); const shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks @@ -831,17 +833,32 @@ namespace ts { if (!resolvedProjectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); } + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference + }); + } if (rootNames.length) { for (const parsedRef of resolvedProjectReferences) { if (!parsedRef) continue; const out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; - if (out) { - processSourceFile(changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + if (useSourceOfProjectReferenceRedirect) { + if (out || getEmitModuleKind(parsedRef.commandLine.options) === ModuleKind.None) { + for (const fileName of parsedRef.commandLine.fileNames) { + processSourceFile(fileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + } } - else if (getEmitModuleKind(parsedRef.commandLine.options) === ModuleKind.None) { - for (const fileName of parsedRef.commandLine.fileNames) { - if (!fileExtensionIs(fileName, Extension.Dts) && hasTSFileExtension(fileName)) { - processSourceFile(getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + else { + if (out) { + processSourceFile(changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + else if (getEmitModuleKind(parsedRef.commandLine.options) === ModuleKind.None) { + for (const fileName of parsedRef.commandLine.fileNames) { + if (!fileExtensionIs(fileName, Extension.Dts) && hasTSFileExtension(fileName)) { + processSourceFile(getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } } } } @@ -955,6 +972,7 @@ namespace ts { getResolvedProjectReferenceToRedirect, getResolvedProjectReferenceByPath, forEachResolvedProjectReference, + isSourceOfProjectReferenceRedirect, emitBuildInfo }; @@ -987,9 +1005,15 @@ namespace ts { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); } + function isValidSourceFileForEmit(file: SourceFile) { + // source file is allowed to be emitted and its not source of project reference redirect + return sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) && + !isSourceOfProjectReferenceRedirect(file.fileName); + } + function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - const emittedFiles = filter(files, file => sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)); + const emittedFiles = filter(files, file => isValidSourceFileForEmit(file)); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified use it as the commonSourceDirectory commonSourceDirectory = getNormalizedAbsolutePath(options.rootDir, currentDirectory); @@ -1220,6 +1244,12 @@ namespace ts { } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference + }); + } } // check if program source files has changed in the way that can affect structure of the program @@ -1359,18 +1389,16 @@ namespace ts { // try to verify results of module resolution for (const { oldFile: oldSourceFile, newFile: newSourceFile } of modifiedSourceFiles) { const newSourceFilePath = getNormalizedAbsolutePath(newSourceFile.originalFileName, currentDirectory); - if (resolveModuleNamesWorker) { - const moduleNames = getModuleNames(newSourceFile); - const resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); - // ensure that module resolution results are still correct - const resolutionsChanged = hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo); - if (resolutionsChanged) { - oldProgram.structureIsReused = StructureIsReused.SafeModules; - newSourceFile.resolvedModules = zipToMap(moduleNames, resolutions); - } - else { - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - } + const moduleNames = getModuleNames(newSourceFile); + const resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); + // ensure that module resolution results are still correct + const resolutionsChanged = hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo); + if (resolutionsChanged) { + oldProgram.structureIsReused = StructureIsReused.SafeModules; + newSourceFile.resolvedModules = zipToMap(moduleNames, resolutions); + } + else { + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; } if (resolveTypeReferenceDirectiveNamesWorker) { // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. @@ -1403,6 +1431,13 @@ namespace ts { for (const newSourceFile of newSourceFiles) { const filePath = newSourceFile.path; addFileToFilesByName(newSourceFile, filePath, newSourceFile.resolvedPath); + if (useSourceOfProjectReferenceRedirect) { + const redirectProject = getProjectReferenceRedirectProject(newSourceFile.fileName); + if (redirectProject && !(redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out)) { + const redirect = getProjectReferenceOutputName(redirectProject, newSourceFile.fileName); + addFileToFilesByName(newSourceFile, toPath(redirect), /*redirectedPath*/ undefined); + } + } // Set the file as found during node modules search if it was found that way in old progra, if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(newSourceFile.resolvedPath)!)) { sourceFilesFoundSearchingNodeModules.set(filePath, true); @@ -1682,7 +1717,7 @@ namespace ts { function getSemanticDiagnosticsForFileNoCache(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] | undefined { return runWithCancellationToken(() => { - if (skipTypeChecking(sourceFile, options)) { + if (skipTypeChecking(sourceFile, options, program)) { return emptyArray; } @@ -2234,6 +2269,16 @@ namespace ts { // Get source file from normalized fileName function findSourceFile(fileName: string, path: Path, isDefaultLib: boolean, ignoreNoDefaultLib: boolean, refFile: RefFile | undefined, packageId: PackageId | undefined): SourceFile | undefined { + if (useSourceOfProjectReferenceRedirect) { + const source = getSourceOfProjectReferenceRedirect(fileName); + if (source) { + const file = isString(source) ? + findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) : + undefined; + if (file) addFileToFilesByName(file, path, /*redirectedPath*/ undefined); + return file; + } + } const originalFileName = fileName; if (filesByName.has(path)) { const file = filesByName.get(path); @@ -2282,7 +2327,7 @@ namespace ts { } let redirectedPath: Path | undefined; - if (refFile) { + if (refFile && !useSourceOfProjectReferenceRedirect) { const redirectProject = getProjectReferenceRedirectProject(fileName); if (redirectProject) { if (redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out) { @@ -2451,6 +2496,36 @@ namespace ts { }); } + function getSourceOfProjectReferenceRedirect(file: string) { + if (!isDeclarationFileName(file)) return undefined; + if (mapFromToProjectReferenceRedirectSource === undefined) { + mapFromToProjectReferenceRedirectSource = createMap(); + forEachResolvedProjectReference(resolvedRef => { + if (resolvedRef) { + const out = resolvedRef.commandLine.options.outFile || resolvedRef.commandLine.options.out; + if (out) { + // Dont know which source file it means so return true? + const outputDts = changeExtension(out, Extension.Dts); + mapFromToProjectReferenceRedirectSource!.set(toPath(outputDts), true); + } + else { + forEach(resolvedRef.commandLine.fileNames, fileName => { + if (!fileExtensionIs(fileName, Extension.Dts) && hasTSFileExtension(fileName)) { + const outputDts = getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); + mapFromToProjectReferenceRedirectSource!.set(toPath(outputDts), fileName); + } + }); + } + } + }); + } + return mapFromToProjectReferenceRedirectSource.get(toPath(file)); + } + + function isSourceOfProjectReferenceRedirect(fileName: string) { + return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName); + } + function forEachProjectReference( projectReferences: readonly ProjectReference[] | undefined, resolvedProjectReferences: readonly (ResolvedProjectReference | undefined)[] | undefined, @@ -2858,8 +2933,7 @@ namespace ts { const rootPaths = arrayToSet(rootNames, toPath); for (const file of files) { // Ignore file that is not emitted - if (!sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) continue; - if (!rootPaths.has(file.path)) { + if (isValidSourceFileForEmit(file) && !rootPaths.has(file.path)) { addProgramDiagnosticAtRefPath( file, rootPaths, diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index ad60d29866d..1de4327d2b4 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -66,6 +66,7 @@ namespace ts { abstract: SyntaxKind.AbstractKeyword, any: SyntaxKind.AnyKeyword, as: SyntaxKind.AsKeyword, + asserts: SyntaxKind.AssertsKeyword, bigint: SyntaxKind.BigIntKeyword, boolean: SyntaxKind.BooleanKeyword, break: SyntaxKind.BreakKeyword, diff --git a/src/compiler/symbolWalker.ts b/src/compiler/symbolWalker.ts index 1f6930076be..b03ef31db6e 100644 --- a/src/compiler/symbolWalker.ts +++ b/src/compiler/symbolWalker.ts @@ -10,7 +10,8 @@ namespace ts { getResolvedSymbol: (node: Node) => Symbol, getIndexTypeOfStructuredType: (type: Type, kind: IndexKind) => Type | undefined, getConstraintOfTypeParameter: (typeParameter: TypeParameter) => Type | undefined, - getFirstIdentifier: (node: EntityNameOrEntityNameExpression) => Identifier) { + getFirstIdentifier: (node: EntityNameOrEntityNameExpression) => Identifier, + getTypeArguments: (type: TypeReference) => readonly Type[]) { return getSymbolWalker; @@ -89,7 +90,7 @@ namespace ts { function visitTypeReference(type: TypeReference): void { visitType(type.target); - forEach(type.typeArguments, visitType); + forEach(getTypeArguments(type), visitType); } function visitTypeParameter(type: TypeParameter): void { diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 2d6286a379e..6a3f4ed86bd 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -522,6 +522,33 @@ namespace ts { } } + function recursiveCreateDirectory(directoryPath: string, sys: System) { + const basePath = getDirectoryPath(directoryPath); + const shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); + if (shouldCreateParent) { + recursiveCreateDirectory(basePath, sys); + } + if (shouldCreateParent || !sys.directoryExists(directoryPath)) { + sys.createDirectory(directoryPath); + } + } + + /** + * patch writefile to create folder before writing the file + */ + /*@internal*/ + export function patchWriteFileEnsuringDirectory(sys: System) { + // patch writefile to create folder before writing the file + const originalWriteFile = sys.writeFile; + sys.writeFile = (path, data, writeBom) => { + const directoryPath = getDirectoryPath(normalizeSlashes(path)); + if (directoryPath && !sys.directoryExists(directoryPath)) { + recursiveCreateDirectory(directoryPath, sys); + } + originalWriteFile.call(sys, path, data, writeBom); + }; + } + /*@internal*/ export type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex"; @@ -651,6 +678,8 @@ namespace ts { base64decode?(input: string): string; base64encode?(input: string): string; /*@internal*/ bufferFrom?(input: string, encoding?: string): Buffer; + // For testing + /*@internal*/ now?(): Date; } export interface FileWatcher { @@ -1365,17 +1394,6 @@ namespace ts { }; } - function recursiveCreateDirectory(directoryPath: string, sys: System) { - const basePath = getDirectoryPath(directoryPath); - const shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); - if (shouldCreateParent) { - recursiveCreateDirectory(basePath, sys); - } - if (shouldCreateParent || !sys.directoryExists(directoryPath)) { - sys.createDirectory(directoryPath); - } - } - let sys: System | undefined; if (typeof ChakraHost !== "undefined") { sys = getChakraSystem(); @@ -1387,14 +1405,7 @@ namespace ts { } if (sys) { // patch writefile to create folder before writing the file - const originalWriteFile = sys.writeFile; - sys.writeFile = (path, data, writeBom) => { - const directoryPath = getDirectoryPath(normalizeSlashes(path)); - if (directoryPath && !sys!.directoryExists(directoryPath)) { - recursiveCreateDirectory(directoryPath, sys!); - } - originalWriteFile.call(sys, path, data, writeBom); - }; + patchWriteFileEnsuringDirectory(sys); } return sys!; })(); diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index 3b1a8379e07..cc16aef6009 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -2871,7 +2871,7 @@ namespace ts { function tryEnterOrLeaveBlock(operationIndex: number): void { if (blocks) { for (; blockIndex < blockActions!.length && blockOffsets![blockIndex] <= operationIndex; blockIndex++) { - const block = blocks[blockIndex]; + const block: CodeBlock = blocks[blockIndex]; const blockAction = blockActions![blockIndex]; switch (block.kind) { case CodeBlockKind.Exception: diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 69b90135fd0..2f152d294a7 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -316,7 +316,7 @@ namespace ts { */ export function createBuilderStatusReporter(system: System, pretty?: boolean): DiagnosticReporter { return diagnostic => { - let output = pretty ? `[${formatColorAndReset(new Date().toLocaleTimeString(), ForegroundColorEscapeSequences.Grey)}] ` : `${new Date().toLocaleTimeString()} - `; + let output = pretty ? `[${formatColorAndReset(getLocaleTimeString(system), ForegroundColorEscapeSequences.Grey)}] ` : `${getLocaleTimeString(system)} - `; output += `${flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)}${system.newLine + system.newLine}`; system.write(output); }; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1828d056405..a10b42b8495 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -32,6 +32,7 @@ namespace ts { | SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword + | SyntaxKind.AssertsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword @@ -250,6 +251,7 @@ namespace ts { // Contextual keywords AbstractKeyword, AsKeyword, + AssertsKeyword, AnyKeyword, AsyncKeyword, AwaitKeyword, @@ -361,8 +363,8 @@ namespace ts { SemicolonClassElement, // Element Block, - VariableStatement, EmptyStatement, + VariableStatement, ExpressionStatement, IfStatement, DoStatement, @@ -512,6 +514,8 @@ namespace ts { LastTemplateToken = TemplateTail, FirstBinaryOperator = LessThanToken, LastBinaryOperator = CaretEqualsToken, + FirstStatement = VariableStatement, + LastStatement = DebuggerStatement, FirstNode = QualifiedName, FirstJSDocNode = JSDocTypeExpression, LastJSDocNode = JSDocPropertyTag, @@ -614,9 +618,13 @@ namespace ts { /* @internal */ export const enum RelationComparisonResult { - Succeeded = 1, // Should be truthy - Failed = 2, - FailedAndReported = 3 + Succeeded = 1 << 0, // Should be truthy + Failed = 1 << 1, + Reported = 1 << 2, + + ReportsUnmeasurable = 1 << 3, + ReportsUnreliable = 1 << 4, + ReportsMask = ReportsUnmeasurable | ReportsUnreliable } export interface Node extends TextRange { @@ -736,6 +744,7 @@ namespace ts { export type AwaitKeywordToken = Token; export type PlusToken = Token; export type MinusToken = Token; + export type AssertsToken = Token; export type Modifier = Token @@ -1037,6 +1046,7 @@ namespace ts { questionToken?: QuestionToken; exclamationToken?: ExclamationToken; body?: Block | Expression; + /* @internal */ endFlowNode?: FlowNode; } export type FunctionLikeDeclaration = @@ -1180,8 +1190,9 @@ namespace ts { export interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; parent: SignatureDeclaration | JSDocTypeExpression; + assertsModifier?: AssertsToken; parameterName: Identifier | ThisTypeNode; - type: TypeNode; + type?: TypeNode; } export interface TypeQueryNode extends TypeNode { @@ -2570,16 +2581,33 @@ namespace ts { FalseCondition = 1 << 6, // Condition known to be false SwitchClause = 1 << 7, // Switch statement clause ArrayMutation = 1 << 8, // Potential array mutation - Referenced = 1 << 9, // Referenced as antecedent once - Shared = 1 << 10, // Referenced as antecedent more than once - PreFinally = 1 << 11, // Injected edge that links pre-finally label and pre-try flow - AfterFinally = 1 << 12, // Injected edge that links post-finally flow with the rest of the graph + Call = 1 << 9, // Potential assertion call + Referenced = 1 << 10, // Referenced as antecedent once + Shared = 1 << 11, // Referenced as antecedent more than once + PreFinally = 1 << 12, // Injected edge that links pre-finally label and pre-try flow + AfterFinally = 1 << 13, // Injected edge that links post-finally flow with the rest of the graph /** @internal */ - Cached = 1 << 13, // Indicates that at least one cross-call cache entry exists for this node, even if not a loop participant + Cached = 1 << 14, // Indicates that at least one cross-call cache entry exists for this node, even if not a loop participant Label = BranchLabel | LoopLabel, Condition = TrueCondition | FalseCondition } + export type FlowNode = + | AfterFinallyFlow + | PreFinallyFlow + | FlowStart + | FlowLabel + | FlowAssignment + | FlowCall + | FlowCondition + | FlowSwitchClause + | FlowArrayMutation; + + export interface FlowNodeBase { + flags: FlowFlags; + id?: number; // Node id used by flow type cache in checker + } + export interface FlowLock { locked?: boolean; } @@ -2593,18 +2621,11 @@ namespace ts { lock: FlowLock; } - export type FlowNode = - | AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation; - export interface FlowNodeBase { - flags: FlowFlags; - id?: number; // Node id used by flow type cache in checker - } - // FlowStart represents the start of a control flow. For a function expression or arrow - // function, the container property references the function (which in turn has a flowNode + // function, the node property references the function (which in turn has a flowNode // property for the containing control flow). export interface FlowStart extends FlowNodeBase { - container?: FunctionExpression | ArrowFunction | MethodDeclaration; + node?: FunctionExpression | ArrowFunction | MethodDeclaration; } // FlowLabel represents a junction with multiple possible preceding control flows. @@ -2619,10 +2640,15 @@ namespace ts { antecedent: FlowNode; } + export interface FlowCall extends FlowNodeBase { + node: CallExpression; + antecedent: FlowNode; + } + // FlowCondition represents a condition that is known to be true or false at the // node's location in the control flow. export interface FlowCondition extends FlowNodeBase { - expression: Expression; + node: Expression; antecedent: FlowNode; } @@ -3039,6 +3065,7 @@ namespace ts { /*@internal*/ getResolvedProjectReferenceToRedirect(fileName: string): ResolvedProjectReference | undefined; /*@internal*/ forEachResolvedProjectReference(cb: (resolvedProjectReference: ResolvedProjectReference | undefined, resolvedProjectReferencePath: Path) => T | undefined): T | undefined; /*@internal*/ getResolvedProjectReferenceByPath(projectReferencePath: Path): ResolvedProjectReference | undefined; + /*@internal*/ isSourceOfProjectReferenceRedirect(fileName: string): boolean; /*@internal*/ getProgramBuildInfo?(): ProgramBuildInfo | undefined; /*@internal*/ emitBuildInfo(writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult; } @@ -3139,6 +3166,7 @@ namespace ts { getSourceFile(fileName: string): SourceFile | undefined; getResolvedTypeReferenceDirectives(): ReadonlyMap; getProjectReferenceRedirect(fileName: string): string | undefined; + isSourceOfProjectReferenceRedirect(fileName: string): boolean; readonly redirectTargetsMap: RedirectTargetsMap; } @@ -3165,6 +3193,7 @@ namespace ts { /* @internal */ getParameterType(signature: Signature, parameterIndex: number): Type; getNullableType(type: Type, flags: TypeFlags): Type; getNonNullableType(type: Type): Type; + getTypeArguments(type: TypeReference): readonly Type[]; // TODO: GH#18217 `xToDeclaration` calls are frequently asserted as defined. /** Note that the resulting nodes cannot be checked. */ @@ -3289,6 +3318,7 @@ namespace ts { /* @internal */ getElementTypeOfArrayType(arrayType: Type): Type | undefined; /* @internal */ createPromiseType(type: Type): Type; + /* @internal */ isTypeAssignableTo(source: Type, target: Type): boolean; /* @internal */ createAnonymousType(symbol: Symbol, members: SymbolTable, callSignatures: Signature[], constructSignatures: Signature[], stringIndexInfo: IndexInfo | undefined, numberIndexInfo: IndexInfo | undefined): Type; /* @internal */ createSignature( declaration: SignatureDeclaration, @@ -3527,25 +3557,45 @@ namespace ts { export const enum TypePredicateKind { This, - Identifier + Identifier, + AssertsThis, + AssertsIdentifier } export interface TypePredicateBase { kind: TypePredicateKind; - type: Type; + type: Type | undefined; } export interface ThisTypePredicate extends TypePredicateBase { kind: TypePredicateKind.This; + parameterName: undefined; + parameterIndex: undefined; + type: Type; } export interface IdentifierTypePredicate extends TypePredicateBase { kind: TypePredicateKind.Identifier; parameterName: string; parameterIndex: number; + type: Type; } - export type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; + export interface AssertsThisTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.AssertsThis; + parameterName: undefined; + parameterIndex: undefined; + type: Type | undefined; + } + + export interface AssertsIdentifierTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.AssertsIdentifier; + parameterName: string; + parameterIndex: number; + type: Type | undefined; + } + + export type TypePredicate = ThisTypePredicate | IdentifierTypePredicate | AssertsThisTypePredicate | AssertsIdentifierTypePredicate; /* @internal */ export type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration; @@ -3963,7 +4013,7 @@ namespace ts { resolvedSignature?: Signature; // Cached signature of signature node or call expression resolvedSymbol?: Symbol; // Cached name resolution result resolvedIndexInfo?: IndexInfo; // Cached indexing info resolution result - maybeTypePredicate?: boolean; // Cached check whether call expression might reference a type predicate + effectsSignature?: Signature; // Signature with possible control flow effects enumMemberValue?: string | number; // Constant value of enum member isVisible?: boolean; // Is this node visible containsArgumentsReference?: boolean; // Whether a function-like declaration contains an 'arguments' reference @@ -3978,6 +4028,9 @@ namespace ts { contextFreeType?: Type; // Cached context-free type used by the first pass of inference; used when a function's return is partially contextually sensitive deferredNodes?: Map; // Set of nodes whose checking has been deferred capturedBlockScopeBindings?: Symbol[]; // Block-scoped bindings captured beneath this part of an IterationStatement + outerTypeParameters?: TypeParameter[]; // Outer type parameters of anonymous object type + instantiations?: Map; // Instantiations of generic type alias (undefined if non-generic) + isExhaustive?: boolean; // Is node an exhaustive switch statement } export const enum TypeFlags { @@ -4202,7 +4255,7 @@ namespace ts { } // Object type or intersection of object types - export type BaseType = ObjectType | IntersectionType; + export type BaseType = ObjectType | IntersectionType | TypeVariable; // Also `any` and `object` export interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; // Declared members @@ -4224,11 +4277,22 @@ namespace ts { */ export interface TypeReference extends ObjectType { target: GenericType; // Type reference target - typeArguments?: readonly Type[]; // Type reference type arguments (undefined if none) + node?: TypeReferenceNode | ArrayTypeNode | TupleTypeNode; + /* @internal */ + mapper?: TypeMapper; + /* @internal */ + resolvedTypeArguments?: readonly Type[]; // Resolved type reference type arguments /* @internal */ literalType?: TypeReference; // Clone of type with ObjectFlags.ArrayLiteral set } + export interface DeferredTypeReference extends TypeReference { + /* @internal */ + node: TypeReferenceNode | ArrayTypeNode | TupleTypeNode; + /* @internal */ + mapper?: TypeMapper; + } + /* @internal */ export const enum VarianceFlags { Invariant = 0, // Neither covariant nor contravariant @@ -4631,6 +4695,8 @@ namespace ts { code: number; message: string; reportsUnnecessary?: {}; + /* @internal */ + elidedInCompatabilityPyramid?: boolean; } /** @@ -4725,6 +4791,7 @@ namespace ts { /* @internal */ diagnostics?: boolean; /* @internal */ extendedDiagnostics?: boolean; disableSizeLimit?: boolean; + disableSourceOfProjectReferenceRedirect?: boolean; downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; @@ -5253,11 +5320,23 @@ namespace ts { /* @internal */ hasChangedAutomaticTypeDirectiveNames?: boolean; createHash?(data: string): string; getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; + /* @internal */ setResolvedProjectReferenceCallbacks?(callbacks: ResolvedProjectReferenceCallbacks): void; + /* @internal */ useSourceOfProjectReferenceRedirect?(): boolean; // TODO: later handle this in better way in builder host instead once the api for tsbuild finalizes and doesn't use compilerHost as base /*@internal*/createDirectory?(directory: string): void; } + /** true if --out otherwise source file name */ + /*@internal*/ + export type SourceOfProjectReferenceRedirect = string | true; + + /*@internal*/ + export interface ResolvedProjectReferenceCallbacks { + getSourceOfProjectReferenceRedirect(fileName: string): SourceOfProjectReferenceRedirect | undefined; + forEachResolvedProjectReference(cb: (resolvedProjectReference: ResolvedProjectReference | undefined, resolvedProjectReferencePath: Path) => T | undefined): T | undefined; + } + /* @internal */ export const enum TransformFlags { None = 0, diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 1645b9339ae..6b48cb80625 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -8713,11 +8713,16 @@ namespace ts { return { pos: typeParameters.pos - 1, end: typeParameters.end + 1 }; } - export function skipTypeChecking(sourceFile: SourceFile, options: CompilerOptions) { + export interface HostWithIsSourceOfProjectReferenceRedirect { + isSourceOfProjectReferenceRedirect(fileName: string): boolean; + } + export function skipTypeChecking(sourceFile: SourceFile, options: CompilerOptions, host: HostWithIsSourceOfProjectReferenceRedirect) { // If skipLibCheck is enabled, skip reporting errors if file is a declaration file. // If skipDefaultLibCheck is enabled, skip reporting errors if file contains a // '/// ' directive. - return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib; + return (options.skipLibCheck && sourceFile.isDeclarationFile || + options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) || + host.isSourceOfProjectReferenceRedirect(sourceFile.fileName); } export function isJsonEqual(a: unknown, b: unknown): boolean { diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 8b7805e6905..3ef382cd10f 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -333,7 +333,8 @@ namespace ts { // Types case SyntaxKind.TypePredicate: - return updateTypePredicateNode(node, + return updateTypePredicateNodeWithModifier(node, + visitNode((node).assertsModifier, visitor), visitNode((node).parameterName, visitor), visitNode((node).type, visitor, isTypeNode)); diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index 652b85d000d..3ee30ae28c3 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -54,6 +54,15 @@ namespace ts { : newLine; } + /** + * Get locale specific time based on whether we are in test mode + */ + export function getLocaleTimeString(system: System) { + return !system.now ? + new Date().toLocaleTimeString() : + system.now().toLocaleTimeString("en-US", { timeZone: "UTC" }); + } + /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ @@ -61,7 +70,7 @@ namespace ts { return pretty ? (diagnostic, newLine, options) => { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - let output = `[${formatColorAndReset(new Date().toLocaleTimeString(), ForegroundColorEscapeSequences.Grey)}] `; + let output = `[${formatColorAndReset(getLocaleTimeString(system), ForegroundColorEscapeSequences.Grey)}] `; output += `${flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)}${newLine + newLine}`; system.write(output); } : @@ -72,7 +81,7 @@ namespace ts { output += newLine; } - output += `${new Date().toLocaleTimeString()} - `; + output += `${getLocaleTimeString(system)} - `; output += `${flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)}${getPlainDiagnosticFollowingNewLines(diagnostic, newLine)}`; system.write(output); @@ -122,7 +131,11 @@ namespace ts { export function listFiles(program: ProgramToEmitFilesAndReportErrors, writeFileName: (s: string) => void) { if (program.getCompilerOptions().listFiles) { forEach(program.getSourceFiles(), file => { - writeFileName(file.fileName); + writeFileName( + !file.redirectInfo ? + file.fileName : + `${file.fileName} -> ${file.redirectInfo.redirectTarget.fileName}` + ); }); } } diff --git a/src/harness/fakes.ts b/src/harness/fakes.ts index 63426bddb48..adcaef55471 100644 --- a/src/harness/fakes.ts +++ b/src/harness/fakes.ts @@ -140,7 +140,7 @@ namespace fakes { } public createHash(data: string): string { - return data; + return `${ts.generateDjb2Hash(data)}-${data}`; } public realpath(path: string) { @@ -164,6 +164,10 @@ namespace fakes { return undefined; } } + + now() { + return new Date(this.vfs.time()); + } } /** @@ -520,39 +524,51 @@ ${indentText}${text}`; export const version = "FakeTSVersion"; - export class SolutionBuilderHost extends CompilerHost implements ts.SolutionBuilderHost { - createProgram: ts.CreateProgram; - - constructor(sys: System | vfs.FileSystem, options?: ts.CompilerOptions, setParentNodes?: boolean, createProgram?: ts.CreateProgram) { - super(sys, options, setParentNodes); - this.createProgram = createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram; - } - - readFile(path: string) { - const value = super.readFile(path); + export function patchSolutionBuilderHost(host: ts.SolutionBuilderHost, sys: System) { + const originalReadFile = host.readFile; + host.readFile = (path, encoding) => { + const value = originalReadFile.call(host, path, encoding); if (!value || !ts.isBuildInfoFile(path)) return value; const buildInfo = ts.getBuildInfo(value); ts.Debug.assert(buildInfo.version === version); buildInfo.version = ts.version; return ts.getBuildInfoText(buildInfo); + }; + + if (host.writeFile) { + const originalWriteFile = host.writeFile; + host.writeFile = (fileName, content, writeByteOrderMark) => { + if (!ts.isBuildInfoFile(fileName)) return originalWriteFile.call(host, fileName, content, writeByteOrderMark); + const buildInfo = ts.getBuildInfo(content); + sanitizeBuildInfoProgram(buildInfo); + buildInfo.version = version; + originalWriteFile.call(host, fileName, ts.getBuildInfoText(buildInfo), writeByteOrderMark); + }; } - public writeFile(fileName: string, content: string, writeByteOrderMark: boolean) { - if (!ts.isBuildInfoFile(fileName)) return super.writeFile(fileName, content, writeByteOrderMark); - const buildInfo = ts.getBuildInfo(content); - sanitizeBuildInfoProgram(buildInfo); - buildInfo.version = version; - super.writeFile(fileName, ts.getBuildInfoText(buildInfo), writeByteOrderMark); + ts.Debug.assert(host.now === undefined); + host.now = () => new Date(sys.vfs.time()); + ts.Debug.assertDefined(host.createHash); + } + + export class SolutionBuilderHost extends CompilerHost implements ts.SolutionBuilderHost { + createProgram: ts.CreateProgram; + + private constructor(sys: System | vfs.FileSystem, options?: ts.CompilerOptions, setParentNodes?: boolean, createProgram?: ts.CreateProgram) { + super(sys, options, setParentNodes); + this.createProgram = createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram; + } + + static create(sys: System | vfs.FileSystem, options?: ts.CompilerOptions, setParentNodes?: boolean, createProgram?: ts.CreateProgram) { + const host = new SolutionBuilderHost(sys, options, setParentNodes, createProgram); + patchSolutionBuilderHost(host, host.sys); + return host; } createHash(data: string) { return `${ts.generateDjb2Hash(data)}-${data}`; } - now() { - return new Date(this.sys.vfs.time()); - } - diagnostics: SolutionBuilderDiagnostic[] = []; reportDiagnostic(diagnostic: ts.Diagnostic) { diff --git a/src/harness/virtualFileSystemWithWatch.ts b/src/harness/virtualFileSystemWithWatch.ts index 1a2fd5f4cc8..0417ad55c99 100644 --- a/src/harness/virtualFileSystemWithWatch.ts +++ b/src/harness/virtualFileSystemWithWatch.ts @@ -44,7 +44,10 @@ interface Array { length: number; [n: number]: T; }` } export function createServerHost(fileOrFolderList: readonly FileOrFolderOrSymLink[], params?: TestServerHostCreationParameters): TestServerHost { - return new TestServerHost(/*withSafelist*/ true, fileOrFolderList, params); + const host = new TestServerHost(/*withSafelist*/ true, fileOrFolderList, params); + // Just like sys, patch the host to use writeFile + patchWriteFileEnsuringDirectory(host); + return host; } export interface File { @@ -174,8 +177,8 @@ interface Array { length: number; [n: number]: T; }` } } - export function checkWatchedFiles(host: TestServerHost, expectedFiles: string[]) { - checkMapKeys("watchedFiles", host.watchedFiles, expectedFiles); + export function checkWatchedFiles(host: TestServerHost, expectedFiles: string[], additionalInfo?: string) { + checkMapKeys(`watchedFiles:: ${additionalInfo || ""}::`, host.watchedFiles, expectedFiles); } export function checkWatchedFilesDetailed(host: TestServerHost, expectedFiles: ReadonlyMap): void; @@ -1016,6 +1019,19 @@ interface Array { length: number; [n: number]: T; }` } } + export type TestServerHostTrackingWrittenFiles = TestServerHost & { writtenFiles: Map; }; + + export function changeToHostTrackingWrittenFiles(inputHost: TestServerHost) { + const host = inputHost as TestServerHostTrackingWrittenFiles; + const originalWriteFile = host.writeFile; + host.writtenFiles = createMap(); + host.writeFile = (fileName, content) => { + originalWriteFile.call(host, fileName, content); + const path = host.toFullPath(fileName); + host.writtenFiles.set(path, true); + }; + return host; + } export const tsbuildProjectsLocation = "/user/username/projects"; export function getTsBuildProjectFilePath(project: string, file: string) { return `${tsbuildProjectsLocation}/${project}/${file}`; diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 7dfccb327ea..b8ea021c4f5 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1235,7 +1235,12 @@ interface Array { slice(start?: number, end?: number): T[]; /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` */ sort(compareFn?: (a: T, b: T) => number): this; /** @@ -1876,8 +1881,12 @@ interface Int8Array { /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` */ sort(compareFn?: (a: number, b: number) => number): this; @@ -2151,8 +2160,12 @@ interface Uint8Array { /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` */ sort(compareFn?: (a: number, b: number) => number): this; @@ -2426,8 +2439,12 @@ interface Uint8ClampedArray { /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` */ sort(compareFn?: (a: number, b: number) => number): this; @@ -2699,8 +2716,12 @@ interface Int16Array { /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` */ sort(compareFn?: (a: number, b: number) => number): this; @@ -2975,8 +2996,12 @@ interface Uint16Array { /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` */ sort(compareFn?: (a: number, b: number) => number): this; @@ -3250,8 +3275,12 @@ interface Int32Array { /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` */ sort(compareFn?: (a: number, b: number) => number): this; @@ -3524,8 +3553,12 @@ interface Uint32Array { /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` */ sort(compareFn?: (a: number, b: number) => number): this; @@ -3799,8 +3832,12 @@ interface Float32Array { /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` */ sort(compareFn?: (a: number, b: number) => number): this; @@ -4075,8 +4112,12 @@ interface Float64Array { /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` */ sort(compareFn?: (a: number, b: number) => number): this; diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 37b4ddc47a5..759eec5d54f 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1777,6 +1777,12 @@ namespace ts.server { configFileErrors.push(...parsedCommandLine.errors); } + this.logger.info(`Config: ${configFilename} : ${JSON.stringify({ + rootNames: parsedCommandLine.fileNames, + options: parsedCommandLine.options, + projectReferences: parsedCommandLine.projectReferences + }, /*replacer*/ undefined, " ")}`); + Debug.assert(!!parsedCommandLine.fileNames); const compilerOptions = parsedCommandLine.options; @@ -1818,7 +1824,7 @@ namespace ts.server { let scriptInfo: ScriptInfo | NormalizedPath; let path: Path; // Use the project's fileExists so that it can use caching instead of reaching to disk for the query - if (!isDynamic && !project.fileExists(newRootFile)) { + if (!isDynamic && !project.fileExistsWithCache(newRootFile)) { path = normalizedPathToPath(normalizedPath, this.currentDirectory, this.toCanonicalFileName); const existingValue = projectRootFilesMap.get(path)!; if (isScriptInfo(existingValue)) { @@ -1851,7 +1857,7 @@ namespace ts.server { projectRootFilesMap.forEach((value, path) => { if (!newRootScriptInfoMap.has(path)) { if (isScriptInfo(value)) { - project.removeFile(value, project.fileExists(path), /*detachFromProject*/ true); + project.removeFile(value, project.fileExistsWithCache(path), /*detachFromProject*/ true); } else { projectRootFilesMap.delete(path); @@ -2584,7 +2590,9 @@ namespace ts.server { /*@internal*/ getOriginalLocationEnsuringConfiguredProject(project: Project, location: DocumentPosition): DocumentPosition | undefined { - const originalLocation = project.getSourceMapper().tryGetSourcePosition(location); + const originalLocation = project.isSourceOfProjectReferenceRedirect(location.fileName) ? + location : + project.getSourceMapper().tryGetSourcePosition(location); if (!originalLocation) return undefined; const { fileName } = originalLocation; @@ -2595,7 +2603,8 @@ namespace ts.server { if (!configFileName) return undefined; const configuredProject = this.findConfiguredProjectByProjectName(configFileName) || - this.createAndLoadConfiguredProject(configFileName, `Creating project for original file: ${originalFileInfo.fileName} for location: ${location.fileName}`); + this.createAndLoadConfiguredProject(configFileName, `Creating project for original file: ${originalFileInfo.fileName}${location !== originalLocation ? " for location: " + location.fileName : ""}`); + if (configuredProject === project) return originalLocation; updateProjectIfDirty(configuredProject); // Keep this configured project as referenced from project addOriginalConfiguredProject(configuredProject); diff --git a/src/server/project.ts b/src/server/project.ts index 4b38a099b2b..418532bdc45 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -196,6 +196,11 @@ namespace ts.server { /*@internal*/ originalConfiguredProjects: Map | undefined; + /*@internal*/ + getResolvedProjectReferenceToRedirect(_fileName: string): ResolvedProjectReference | undefined { + return undefined; + } + private readonly cancellationToken: ThrottledCancellationToken; public isNonTsProject() { @@ -391,6 +396,11 @@ namespace ts.server { } fileExists(file: string): boolean { + return this.fileExistsWithCache(file); + } + + /* @internal */ + fileExistsWithCache(file: string): boolean { // As an optimization, don't hit the disks for files we already know don't exist // (because we're watching for their creation). const path = this.toPath(file); @@ -527,8 +537,11 @@ namespace ts.server { return this.projectService.getSourceFileLike(fileName, this); } - private shouldEmitFile(scriptInfo: ScriptInfo) { - return scriptInfo && !scriptInfo.isDynamicOrHasMixedContent(); + /*@internal*/ + shouldEmitFile(scriptInfo: ScriptInfo | undefined) { + return scriptInfo && + !scriptInfo.isDynamicOrHasMixedContent() && + !this.program!.isSourceOfProjectReferenceRedirect(scriptInfo.path); } getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[] { @@ -538,7 +551,7 @@ namespace ts.server { updateProjectIfDirty(this); this.builderState = BuilderState.create(this.program!, this.projectService.toCanonicalFileName, this.builderState); return mapDefined(BuilderState.getFilesAffectedBy(this.builderState, this.program!, scriptInfo.path, this.cancellationToken, data => this.projectService.host.createHash!(data)), // TODO: GH#18217 - sourceFile => this.shouldEmitFile(this.projectService.getScriptInfoForPath(sourceFile.path)!) ? sourceFile.fileName : undefined); + sourceFile => this.shouldEmitFile(this.projectService.getScriptInfoForPath(sourceFile.path)) ? sourceFile.fileName : undefined); } /** @@ -1223,6 +1236,11 @@ namespace ts.server { this.rootFilesMap.delete(info.path); } + /*@internal*/ + isSourceOfProjectReferenceRedirect(fileName: string) { + return !!this.program && this.program.isSourceOfProjectReferenceRedirect(fileName); + } + protected enableGlobalPlugins(options: CompilerOptions, pluginConfigOverrides: Map | undefined) { const host = this.projectService.host; @@ -1475,6 +1493,8 @@ namespace ts.server { configFileWatcher: FileWatcher | undefined; private directoriesWatchedForWildcards: Map | undefined; readonly canonicalConfigFilePath: NormalizedPath; + private projectReferenceCallbacks: ResolvedProjectReferenceCallbacks | undefined; + private mapOfDeclarationDirectories: Map | undefined; /* @internal */ pendingReload: ConfigFileProgramReloadLevel | undefined; @@ -1520,6 +1540,63 @@ namespace ts.server { this.canonicalConfigFilePath = asNormalizedPath(projectService.toCanonicalFileName(configFileName)); } + /* @internal */ + setResolvedProjectReferenceCallbacks(projectReferenceCallbacks: ResolvedProjectReferenceCallbacks) { + this.projectReferenceCallbacks = projectReferenceCallbacks; + } + + /* @internal */ + useSourceOfProjectReferenceRedirect = () => !!this.languageServiceEnabled && + !this.getCompilerOptions().disableSourceOfProjectReferenceRedirect; + + /** + * This implementation of fileExists checks if the file being requested is + * .d.ts file for the referenced Project. + * If it is it returns true irrespective of whether that file exists on host + */ + fileExists(file: string): boolean { + // Project references go to source file instead of .d.ts file + if (this.useSourceOfProjectReferenceRedirect() && this.projectReferenceCallbacks) { + const source = this.projectReferenceCallbacks.getSourceOfProjectReferenceRedirect(file); + if (source) return isString(source) ? super.fileExists(source) : true; + } + return super.fileExists(file); + } + + /** + * This implementation of directoryExists checks if the directory being requested is + * directory of .d.ts file for the referenced Project. + * If it is it returns true irrespective of whether that directory exists on host + */ + directoryExists(path: string): boolean { + if (super.directoryExists(path)) return true; + if (!this.useSourceOfProjectReferenceRedirect() || !this.projectReferenceCallbacks) return false; + + if (!this.mapOfDeclarationDirectories) { + this.mapOfDeclarationDirectories = createMap(); + this.projectReferenceCallbacks.forEachResolvedProjectReference(ref => { + if (!ref) return; + const out = ref.commandLine.options.outFile || ref.commandLine.options.outDir; + if (out) { + this.mapOfDeclarationDirectories!.set(getDirectoryPath(this.toPath(out)), true); + } + else { + // Set declaration's in different locations only, if they are next to source the directory present doesnt change + const declarationDir = ref.commandLine.options.declarationDir || ref.commandLine.options.outDir; + if (declarationDir) { + this.mapOfDeclarationDirectories!.set(this.toPath(declarationDir), true); + } + } + }); + } + const dirPath = this.toPath(path); + const dirPathWithTrailingDirectorySeparator = `${dirPath}${directorySeparator}`; + return !!forEachKey( + this.mapOfDeclarationDirectories, + declDirPath => dirPath === declDirPath || startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) + ); + } + /** * If the project has reload from disk pending, it reloads (and then updates graph as part of that) instead of just updating the graph * @returns: true if set of files in the project stays the same and false - otherwise. @@ -1528,6 +1605,8 @@ namespace ts.server { this.isInitialLoadPending = returnFalse; const reloadLevel = this.pendingReload; this.pendingReload = ConfigFileProgramReloadLevel.None; + this.projectReferenceCallbacks = undefined; + this.mapOfDeclarationDirectories = undefined; let result: boolean; switch (reloadLevel) { case ConfigFileProgramReloadLevel.Partial: @@ -1570,6 +1649,12 @@ namespace ts.server { return program && program.forEachResolvedProjectReference(cb); } + /*@internal*/ + getResolvedProjectReferenceToRedirect(fileName: string): ResolvedProjectReference | undefined { + const program = this.getCurrentProgram(); + return program && program.getResolvedProjectReferenceToRedirect(fileName); + } + /*@internal*/ enablePluginsWithOptions(options: CompilerOptions, pluginConfigOverrides: Map | undefined) { const host = this.projectService.host; @@ -1652,6 +1737,8 @@ namespace ts.server { this.stopWatchingWildCards(); this.projectErrors = undefined; this.configFileSpecs = undefined; + this.projectReferenceCallbacks = undefined; + this.mapOfDeclarationDirectories = undefined; super.close(); } diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts index e441ca54d37..cbd006dd9d2 100644 --- a/src/server/scriptInfo.ts +++ b/src/server/scriptInfo.ts @@ -495,15 +495,17 @@ namespace ts.server { // the default project; if no configured projects, the first external project should // be the default project; otherwise the first inferred project should be the default. let firstExternalProject; + let firstConfiguredProject; for (const project of this.containingProjects) { if (project.projectKind === ProjectKind.Configured) { - return project; + if (!project.isSourceOfProjectReferenceRedirect(this.fileName)) return project; + if (!firstConfiguredProject) firstConfiguredProject = project; } else if (project.projectKind === ProjectKind.External && !firstExternalProject) { firstExternalProject = project; } } - return firstExternalProject || this.containingProjects[0]; + return firstConfiguredProject || firstExternalProject || this.containingProjects[0]; } } diff --git a/src/server/session.ts b/src/server/session.ts index f2996b98dd8..6fe392c722b 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -448,7 +448,9 @@ namespace ts.server { function getDefinitionInProject(definition: DocumentPosition | undefined, definingProject: Project, project: Project): DocumentPosition | undefined { if (!definition || project.containsFile(toNormalizedPath(definition.fileName))) return definition; - const mappedDefinition = definingProject.getLanguageService().getSourceMapper().tryGetGeneratedPosition(definition); + const mappedDefinition = definingProject.isSourceOfProjectReferenceRedirect(definition.fileName) ? + definition : + definingProject.getLanguageService().getSourceMapper().tryGetGeneratedPosition(definition); return mappedDefinition && project.containsFile(toNormalizedPath(mappedDefinition.fileName)) ? mappedDefinition : undefined; } @@ -477,7 +479,7 @@ namespace ts.server { for (const symlinkedProject of symlinkedProjects) addToTodo({ project: symlinkedProject, location: originalLocation as TLocation }, toDo!, seenProjects); }); } - return originalLocation; + return originalLocation === location ? undefined : originalLocation; }); return toDo; } @@ -1037,7 +1039,9 @@ namespace ts.server { private getEmitOutput(args: protocol.FileRequestArgs): EmitOutput { const { file, project } = this.getFileAndProject(args); - return project.getLanguageService().getEmitOutput(file); + return project.shouldEmitFile(project.getScriptInfo(file)) ? + project.getLanguageService().getEmitOutput(file) : + { emitSkipped: true, outputFiles: [] }; } private mapDefinitionInfo(definitions: readonly DefinitionInfo[], project: Project): readonly protocol.FileSpanWithContext[] { @@ -1672,10 +1676,10 @@ namespace ts.server { } } - private createCheckList(fileNames: string[], defaultProject?: Project): PendingErrorCheck[] { + private createCheckList(fileNames: string[]): PendingErrorCheck[] { return mapDefined(fileNames, uncheckedFileName => { const fileName = toNormalizedPath(uncheckedFileName); - const project = defaultProject || this.projectService.tryGetDefaultProjectForFile(fileName); + const project = this.projectService.tryGetDefaultProjectForFile(fileName); return project && { fileName, project }; }); } diff --git a/src/services/codefixes/inferFromUsage.ts b/src/services/codefixes/inferFromUsage.ts index 60cd06101dc..555c9139573 100644 --- a/src/services/codefixes/inferFromUsage.ts +++ b/src/services/codefixes/inferFromUsage.ts @@ -393,6 +393,19 @@ namespace ts.codefix { function inferTypeFromReferences(program: Program, references: readonly Identifier[], cancellationToken: CancellationToken) { const checker = program.getTypeChecker(); + const builtinConstructors: { [s: string]: (t: Type) => Type } = { + string: () => checker.getStringType(), + number: () => checker.getNumberType(), + Array: t => checker.createArrayType(t), + Promise: t => checker.createPromiseType(t), + }; + const builtins = [ + checker.getStringType(), + checker.getNumberType(), + checker.createArrayType(checker.getAnyType()), + checker.createPromiseType(checker.getAnyType()), + ]; + return { single, parameters, @@ -401,26 +414,74 @@ namespace ts.codefix { interface CallUsage { argumentTypes: Type[]; - returnType: Usage; + return_: Usage; } interface Usage { - isNumber?: boolean; - isString?: boolean; + isNumber: boolean | undefined; + isString: boolean | undefined; /** Used ambiguously, eg x + ___ or object[___]; results in string | number if no other evidence exists */ - isNumberOrString?: boolean; + isNumberOrString: boolean | undefined; - candidateTypes?: Type[]; - properties?: UnderscoreEscapedMap; - calls?: CallUsage[]; - constructs?: CallUsage[]; - numberIndex?: Usage; - stringIndex?: Usage; - candidateThisTypes?: Type[]; + candidateTypes: Type[] | undefined; + properties: UnderscoreEscapedMap | undefined; + calls: CallUsage[] | undefined; + constructs: CallUsage[] | undefined; + numberIndex: Usage | undefined; + stringIndex: Usage | undefined; + candidateThisTypes: Type[] | undefined; + inferredTypes: Type[] | undefined; + } + + function createEmptyUsage(): Usage { + return { + isNumber: undefined, + isString: undefined, + isNumberOrString: undefined, + candidateTypes: undefined, + properties: undefined, + calls: undefined, + constructs: undefined, + numberIndex: undefined, + stringIndex: undefined, + candidateThisTypes: undefined, + inferredTypes: undefined, + }; + } + + function combineUsages(usages: Usage[]): Usage { + const combinedProperties = createUnderscoreEscapedMap(); + for (const u of usages) { + if (u.properties) { + u.properties.forEach((p, name) => { + if (!combinedProperties.has(name)) { + combinedProperties.set(name, []); + } + combinedProperties.get(name)!.push(p); + }); + } + } + const properties = createUnderscoreEscapedMap(); + combinedProperties.forEach((ps, name) => { + properties.set(name, combineUsages(ps)); + }); + return { + isNumber: usages.some(u => u.isNumber), + isString: usages.some(u => u.isString), + isNumberOrString: usages.some(u => u.isNumberOrString), + candidateTypes: flatMap(usages, u => u.candidateTypes) as Type[], + properties, + calls: flatMap(usages, u => u.calls) as CallUsage[], + constructs: flatMap(usages, u => u.constructs) as CallUsage[], + numberIndex: forEach(usages, u => u.numberIndex), + stringIndex: forEach(usages, u => u.stringIndex), + candidateThisTypes: flatMap(usages, u => u.candidateThisTypes) as Type[], + inferredTypes: undefined, // clear type cache + }; } function single(): Type { - return unifyFromUsage(inferTypesFromReferencesSingle(references)); + return combineTypes(inferTypesFromReferencesSingle(references)); } function parameters(declaration: FunctionLike): ParameterInference[] | undefined { @@ -428,7 +489,7 @@ namespace ts.codefix { return undefined; } - const usage: Usage = {}; + const usage = createEmptyUsage(); for (const reference of references) { cancellationToken.throwIfCancellationRequested(); calculateUsageOfNode(reference, usage); @@ -456,7 +517,7 @@ namespace ts.codefix { const inferred = inferTypesFromReferencesSingle(getReferences(parameter.name, program, cancellationToken)); types.push(...(isRest ? mapDefined(inferred, checker.getElementTypeOfArrayType) : inferred)); } - const type = unifyFromUsage(types); + const type = combineTypes(types); return { type: isRest ? checker.createArrayType(type) : type, isOptional: isOptional && !isRest, @@ -466,22 +527,22 @@ namespace ts.codefix { } function thisParameter() { - const usage: Usage = {}; + const usage = createEmptyUsage(); for (const reference of references) { cancellationToken.throwIfCancellationRequested(); calculateUsageOfNode(reference, usage); } - return unifyFromUsage(usage.candidateThisTypes || emptyArray); + return combineTypes(usage.candidateThisTypes || emptyArray); } function inferTypesFromReferencesSingle(references: readonly Identifier[]): Type[] { - const usage: Usage = {}; + const usage: Usage = createEmptyUsage(); for (const reference of references) { cancellationToken.throwIfCancellationRequested(); calculateUsageOfNode(reference, usage); } - return inferFromUsage(usage); + return inferTypes(usage); } function calculateUsageOfNode(node: Expression, usage: Usage): void { @@ -490,6 +551,9 @@ namespace ts.codefix { } switch (node.parent.kind) { + case SyntaxKind.ExpressionStatement: + addCandidateType(usage, checker.getVoidType()); + break; case SyntaxKind.PostfixUnaryExpression: usage.isNumber = true; break; @@ -632,6 +696,9 @@ namespace ts.codefix { else if (otherOperandType.flags & TypeFlags.StringLike) { usage.isString = true; } + else if (otherOperandType.flags & TypeFlags.Any) { + // do nothing, maybe we'll learn something elsewhere + } else { usage.isNumberOrString = true; } @@ -677,7 +744,7 @@ namespace ts.codefix { function inferTypeFromCallExpression(parent: CallExpression | NewExpression, usage: Usage): void { const call: CallUsage = { argumentTypes: [], - returnType: {} + return_: createEmptyUsage() }; if (parent.arguments) { @@ -686,7 +753,7 @@ namespace ts.codefix { } } - calculateUsageOfNode(parent, call.returnType); + calculateUsageOfNode(parent, call.return_); if (parent.kind === SyntaxKind.CallExpression) { (usage.calls || (usage.calls = [])).push(call); } @@ -700,7 +767,7 @@ namespace ts.codefix { if (!usage.properties) { usage.properties = createUnderscoreEscapedMap(); } - const propertyUsage = usage.properties.get(name) || { }; + const propertyUsage = usage.properties.get(name) || createEmptyUsage(); calculateUsageOfNode(parent, propertyUsage); usage.properties.set(name, propertyUsage); } @@ -712,7 +779,7 @@ namespace ts.codefix { } else { const indexType = checker.getTypeAtLocation(parent.argumentExpression); - const indexUsage = {}; + const indexUsage = createEmptyUsage(); calculateUsageOfNode(parent, indexUsage); if (indexType.flags & TypeFlags.NumberLike) { usage.numberIndex = indexUsage; @@ -752,8 +819,12 @@ namespace ts.codefix { return inferences.filter(i => toRemove.every(f => !f(i))); } - function unifyFromUsage(inferences: readonly Type[], fallback = checker.getAnyType()): Type { - if (!inferences.length) return fallback; + function combineFromUsage(usage: Usage) { + return combineTypes(inferTypes(usage)); + } + + function combineTypes(inferences: readonly Type[]): Type { + if (!inferences.length) return checker.getAnyType(); // 1. string or number individually override string | number // 2. non-any, non-void overrides any or void @@ -776,12 +847,12 @@ namespace ts.codefix { const anons = good.filter(i => checker.getObjectFlags(i) & ObjectFlags.Anonymous) as AnonymousType[]; if (anons.length) { good = good.filter(i => !(checker.getObjectFlags(i) & ObjectFlags.Anonymous)); - good.push(unifyAnonymousTypes(anons)); + good.push(combineAnonymousTypes(anons)); } - return checker.getWidenedType(checker.getUnionType(good)); + return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), UnionReduction.Subtype)); } - function unifyAnonymousTypes(anons: AnonymousType[]) { + function combineAnonymousTypes(anons: AnonymousType[]) { if (anons.length === 1) { return anons[0]; } @@ -822,7 +893,7 @@ namespace ts.codefix { numberIndices.length ? checker.createIndexInfo(checker.getUnionType(numberIndices), numberIndexReadonly) : undefined); } - function inferFromUsage(usage: Usage) { + function inferTypes(usage: Usage): Type[] { const types = []; if (usage.isNumber) { @@ -834,92 +905,155 @@ namespace ts.codefix { if (usage.isNumberOrString) { types.push(checker.getUnionType([checker.getStringType(), checker.getNumberType()])); } + if (usage.numberIndex) { + types.push(checker.createArrayType(combineFromUsage(usage.numberIndex))); + } + if (usage.properties && usage.properties.size + || usage.calls && usage.calls.length + || usage.constructs && usage.constructs.length + || usage.stringIndex) { + types.push(inferStructuralType(usage)); + } types.push(...(usage.candidateTypes || []).map(t => checker.getBaseTypeOfLiteralType(t))); + types.push(...inferNamedTypesFromProperties(usage)); - if (usage.properties && hasCalls(usage.properties.get("then" as __String))) { - const paramType = getParameterTypeFromCalls(0, usage.properties.get("then" as __String)!.calls!, /*isRestParameter*/ false)!; // TODO: GH#18217 - const types = paramType.getCallSignatures().map(sig => sig.getReturnType()); - types.push(checker.createPromiseType(types.length ? checker.getUnionType(types, UnionReduction.Subtype) : checker.getAnyType())); - } - else if (usage.properties && hasCalls(usage.properties.get("push" as __String))) { - types.push(checker.createArrayType(getParameterTypeFromCalls(0, usage.properties.get("push" as __String)!.calls!, /*isRestParameter*/ false)!)); - } - - if (usage.numberIndex) { - types.push(checker.createArrayType(recur(usage.numberIndex))); - } - else if (usage.properties || usage.calls || usage.constructs || usage.stringIndex) { - const members = createUnderscoreEscapedMap(); - const callSignatures: Signature[] = []; - const constructSignatures: Signature[] = []; - let stringIndexInfo: IndexInfo | undefined; - - if (usage.properties) { - usage.properties.forEach((u, name) => { - const symbol = checker.createSymbol(SymbolFlags.Property, name); - symbol.type = recur(u); - members.set(name, symbol); - }); - } - - if (usage.calls) { - for (const call of usage.calls) { - callSignatures.push(getSignatureFromCall(call)); - } - } - - if (usage.constructs) { - for (const construct of usage.constructs) { - constructSignatures.push(getSignatureFromCall(construct)); - } - } - - if (usage.stringIndex) { - stringIndexInfo = checker.createIndexInfo(recur(usage.stringIndex), /*isReadonly*/ false); - } - - types.push(checker.createAnonymousType(/*symbol*/ undefined!, members, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined)); // TODO: GH#18217 - } return types; - - function recur(innerUsage: Usage): Type { - return unifyFromUsage(inferFromUsage(innerUsage)); - } } - function getParameterTypeFromCalls(parameterIndex: number, calls: CallUsage[], isRestParameter: boolean) { - let types: Type[] = []; - if (calls) { - for (const call of calls) { - if (call.argumentTypes.length > parameterIndex) { - if (isRestParameter) { - types = concatenate(types, map(call.argumentTypes.slice(parameterIndex), a => checker.getBaseTypeOfLiteralType(a))); - } - else { - types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex])); + function inferStructuralType(usage: Usage) { + const members = createUnderscoreEscapedMap(); + if (usage.properties) { + usage.properties.forEach((u, name) => { + const symbol = checker.createSymbol(SymbolFlags.Property, name); + symbol.type = combineFromUsage(u); + members.set(name, symbol); + }); + } + const callSignatures: Signature[] = usage.calls ? [getSignatureFromCalls(usage.calls)] : []; + const constructSignatures: Signature[] = usage.constructs ? [getSignatureFromCalls(usage.constructs)] : []; + const stringIndexInfo = usage.stringIndex && checker.createIndexInfo(combineFromUsage(usage.stringIndex), /*isReadonly*/ false); + return checker.createAnonymousType(/*symbol*/ undefined!, members, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217 + } + + function inferNamedTypesFromProperties(usage: Usage): Type[] { + if (!usage.properties || !usage.properties.size) return []; + const types = builtins.filter(t => allPropertiesAreAssignableToUsage(t, usage)); + if (0 < types.length && types.length < 3) { + return types.map(t => inferInstantiationFromUsage(t, usage)); + } + return []; + } + + function allPropertiesAreAssignableToUsage(type: Type, usage: Usage) { + if (!usage.properties) return false; + return !forEachEntry(usage.properties, (propUsage, name) => { + const source = checker.getTypeOfPropertyOfType(type, name as string); + if (!source) { + return true; + } + if (propUsage.calls) { + const sigs = checker.getSignaturesOfType(source, SignatureKind.Call); + return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls)); + } + else { + return !checker.isTypeAssignableTo(source, combineFromUsage(propUsage)); + } + }); + } + + /** + * inference is limited to + * 1. generic types with a single parameter + * 2. inference to/from calls with a single signature + */ + function inferInstantiationFromUsage(type: Type, usage: Usage) { + if (!(getObjectFlags(type) & ObjectFlags.Reference) || !usage.properties) { + return type; + } + const generic = (type as TypeReference).target; + const singleTypeParameter = singleOrUndefined(generic.typeParameters); + if (!singleTypeParameter) return type; + + const types: Type[] = []; + usage.properties.forEach((propUsage, name) => { + const genericPropertyType = checker.getTypeOfPropertyOfType(generic, name as string); + Debug.assert(!!genericPropertyType, "generic should have all the properties of its reference."); + types.push(...inferTypeParameters(genericPropertyType!, combineFromUsage(propUsage), singleTypeParameter)); + }); + return builtinConstructors[type.symbol.escapedName as string](combineTypes(types)); + } + + function inferTypeParameters(genericType: Type, usageType: Type, typeParameter: Type): readonly Type[] { + if (genericType === typeParameter) { + return [usageType]; + } + else if (genericType.flags & TypeFlags.UnionOrIntersection) { + return flatMap((genericType as UnionOrIntersectionType).types, t => inferTypeParameters(t, usageType, typeParameter)); + } + else if (getObjectFlags(genericType) & ObjectFlags.Reference && getObjectFlags(usageType) & ObjectFlags.Reference) { + // this is wrong because we need a reference to the targetType to, so we can check that it's also a reference + const genericArgs = checker.getTypeArguments(genericType as TypeReference); + const usageArgs = checker.getTypeArguments(usageType as TypeReference); + const types = []; + if (genericArgs && usageArgs) { + for (let i = 0; i < genericArgs.length; i++) { + if (usageArgs[i]) { + types.push(...inferTypeParameters(genericArgs[i], usageArgs[i], typeParameter)); } } } + return types; } - - if (types.length) { - const type = checker.getWidenedType(checker.getUnionType(types, UnionReduction.Subtype)); - return isRestParameter ? checker.createArrayType(type) : type; + const genericSigs = checker.getSignaturesOfType(genericType, SignatureKind.Call); + const usageSigs = checker.getSignaturesOfType(usageType, SignatureKind.Call); + if (genericSigs.length === 1 && usageSigs.length === 1) { + return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter); } - return undefined; + return []; } - function getSignatureFromCall(call: CallUsage): Signature { + function inferFromSignatures(genericSig: Signature, usageSig: Signature, typeParameter: Type) { + const types = []; + for (let i = 0; i < genericSig.parameters.length; i++) { + const genericParam = genericSig.parameters[i]; + const usageParam = usageSig.parameters[i]; + const isRest = genericSig.declaration && isRestParameter(genericSig.declaration.parameters[i]); + if (!usageParam) { + break; + } + let genericParamType = checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration); + const elementType = isRest && checker.getElementTypeOfArrayType(genericParamType); + if (elementType) { + genericParamType = elementType; + } + const targetType = (usageParam as SymbolLinks).type || checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration); + types.push(...inferTypeParameters(genericParamType, targetType, typeParameter)); + } + const genericReturn = checker.getReturnTypeOfSignature(genericSig); + const usageReturn = checker.getReturnTypeOfSignature(usageSig); + types.push(...inferTypeParameters(genericReturn, usageReturn, typeParameter)); + return types; + } + + function getFunctionFromCalls(calls: CallUsage[]) { + return checker.createAnonymousType(undefined!, createSymbolTable(), [getSignatureFromCalls(calls)], emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + } + + function getSignatureFromCalls(calls: CallUsage[]): Signature { const parameters: Symbol[] = []; - for (let i = 0; i < call.argumentTypes.length; i++) { + const length = Math.max(...calls.map(c => c.argumentTypes.length)); + for (let i = 0; i < length; i++) { const symbol = checker.createSymbol(SymbolFlags.FunctionScopedVariable, escapeLeadingUnderscores(`arg${i}`)); - symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(call.argumentTypes[i])); + symbol.type = combineTypes(calls.map(call => call.argumentTypes[i] || checker.getUndefinedType())); + if (calls.some(call => call.argumentTypes[i] === undefined)) { + symbol.flags |= SymbolFlags.Optional; + } parameters.push(symbol); } - const returnType = unifyFromUsage(inferFromUsage(call.returnType), checker.getVoidType()); + const returnType = combineFromUsage(combineUsages(calls.map(call => call.return_))); // TODO: GH#18217 - return checker.createSignature(/*declaration*/ undefined!, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, call.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + return checker.createSignature(/*declaration*/ undefined!, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); } function addCandidateType(usage: Usage, type: Type | undefined) { @@ -933,9 +1067,5 @@ namespace ts.codefix { (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); } } - - function hasCalls(usage: Usage | undefined): boolean { - return !!usage && !!usage.calls; - } } } diff --git a/src/services/services.ts b/src/services/services.ts index 644629ce2af..fb5c35d8f5d 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1149,10 +1149,10 @@ namespace ts { useCaseSensitiveFileNames: () => useCaseSensitiveFileNames, getCurrentDirectory: () => currentDirectory, getProgram, - fileExists: host.fileExists && (f => host.fileExists!(f)), - readFile: host.readFile && ((f, encoding) => host.readFile!(f, encoding)), - getDocumentPositionMapper: host.getDocumentPositionMapper && ((generatedFileName, sourceFileName) => host.getDocumentPositionMapper!(generatedFileName, sourceFileName)), - getSourceFileLike: host.getSourceFileLike && (f => host.getSourceFileLike!(f)), + fileExists: maybeBind(host, host.fileExists), + readFile: maybeBind(host, host.readFile), + getDocumentPositionMapper: maybeBind(host, host.getDocumentPositionMapper), + getSourceFileLike: maybeBind(host, host.getSourceFileLike), log }); @@ -1250,6 +1250,12 @@ namespace ts { if (host.resolveTypeReferenceDirectives) { compilerHost.resolveTypeReferenceDirectives = (...args) => host.resolveTypeReferenceDirectives!(...args); } + if (host.setResolvedProjectReferenceCallbacks) { + compilerHost.setResolvedProjectReferenceCallbacks = callbacks => host.setResolvedProjectReferenceCallbacks!(callbacks); + } + if (host.useSourceOfProjectReferenceRedirect) { + compilerHost.useSourceOfProjectReferenceRedirect = () => host.useSourceOfProjectReferenceRedirect!(); + } const documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); const options: CreateProgramOptions = { diff --git a/src/services/sourcemaps.ts b/src/services/sourcemaps.ts index d07c21a9f43..6ab656b4236 100644 --- a/src/services/sourcemaps.ts +++ b/src/services/sourcemaps.ts @@ -70,6 +70,11 @@ namespace ts { if (!sourceFile) return undefined; const program = host.getProgram()!; + // If this is source file of project reference source (instead of redirect) there is no generated position + if (program.isSourceOfProjectReferenceRedirect(sourceFile.fileName)) { + return undefined; + } + const options = program.getCompilerOptions(); const outPath = options.outFile || options.out; diff --git a/src/services/types.ts b/src/services/types.ts index c44370febe3..d77007f045d 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -234,6 +234,10 @@ namespace ts { getDocumentPositionMapper?(generatedFileName: string, sourceFileName?: string): DocumentPositionMapper | undefined; /* @internal */ getSourceFileLike?(fileName: string): SourceFileLike | undefined; + /* @internal */ + setResolvedProjectReferenceCallbacks?(callbacks: ResolvedProjectReferenceCallbacks): void; + /* @internal */ + useSourceOfProjectReferenceRedirect?(): boolean; } /* @internal */ diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index db9e96e1ad2..49272d6c1b3 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -38,6 +38,7 @@ "unittests/services/extract/helpers.ts", "unittests/tsbuild/helpers.ts", + "unittests/tsc/helpers.ts", "unittests/tscWatch/helpers.ts", "unittests/tsserver/helpers.ts", @@ -108,6 +109,7 @@ "unittests/tsbuild/transitiveReferences.ts", "unittests/tsbuild/watchEnvironment.ts", "unittests/tsbuild/watchMode.ts", + "unittests/tsc/declarationEmit.ts", "unittests/tscWatch/consoleClearing.ts", "unittests/tscWatch/emit.ts", "unittests/tscWatch/emitAndErrorUpdates.ts", @@ -145,6 +147,8 @@ "unittests/tsserver/occurences.ts", "unittests/tsserver/openFile.ts", "unittests/tsserver/projectErrors.ts", + "unittests/tsserver/projectReferenceCompileOnSave.ts", + "unittests/tsserver/projectReferenceErrors.ts", "unittests/tsserver/projectReferences.ts", "unittests/tsserver/projects.ts", "unittests/tsserver/refactors.ts", diff --git a/src/testRunner/unittests/tsbuild/amdModulesWithOut.ts b/src/testRunner/unittests/tsbuild/amdModulesWithOut.ts index 8a62972288d..fdcf748cf2c 100644 --- a/src/testRunner/unittests/tsbuild/amdModulesWithOut.ts +++ b/src/testRunner/unittests/tsbuild/amdModulesWithOut.ts @@ -1,7 +1,6 @@ namespace ts { describe("unittests:: tsbuild:: outFile:: on amd modules with --out", () => { let outFileFs: vfs.FileSystem; - const { time, tick } = getTime(); const enum project { lib, app } function relName(path: string) { return path.slice(1); } type Sources = [string, readonly string[]]; @@ -25,54 +24,52 @@ namespace ts { ] ]; before(() => { - outFileFs = loadProjectFromDisk("tests/projects/amdModulesWithOut", time); + outFileFs = loadProjectFromDisk("tests/projects/amdModulesWithOut"); }); after(() => { outFileFs = undefined!; }); interface VerifyOutFileScenarioInput { - scenario: string; - modifyFs: (fs: vfs.FileSystem) => void; + subScenario: string; + modifyFs?: (fs: vfs.FileSystem) => void; modifyAgainFs?: (fs: vfs.FileSystem) => void; } function verifyOutFileScenario({ - scenario, + subScenario, modifyFs, modifyAgainFs }: VerifyOutFileScenarioInput) { - verifyTsbuildOutput({ - scenario, - projFs: () => outFileFs, - time, - tick, - proj: "amdModulesWithOut", - rootNames: ["/src/app"], + verifyTscIncrementalEdits({ + scenario: "amdModulesWithOut", + subScenario, + fs: () => outFileFs, + commandLineArgs: ["--b", "/src/app", "--verbose"], baselineSourceMap: true, - initialBuild: { - modifyFs - }, - incrementalDtsUnchangedBuild: { - modifyFs: fs => appendText(fs, relName(sources[project.lib][source.ts][1]), "console.log(x);") - }, - incrementalHeaderChangedBuild: modifyAgainFs ? { - modifyFs: modifyAgainFs - } : undefined, - baselineOnly: true + modifyFs, + incrementalScenarios: [ + { + buildKind: BuildKind.IncrementalDtsUnchanged, + modifyFs: fs => appendText(fs, relName(sources[project.lib][source.ts][1]), "console.log(x);") + }, + ...(modifyAgainFs ? [{ + buildKind: BuildKind.IncrementalHeadersChange, + modifyFs: modifyAgainFs + }] : emptyArray), + ] }); } describe("Prepend output with .tsbuildinfo", () => { verifyOutFileScenario({ - scenario: "modules and globals mixed in amd", - modifyFs: noop + subScenario: "modules and globals mixed in amd", }); // Prologues describe("Prologues", () => { verifyOutFileScenario({ - scenario: "multiple prologues in all projects", + subScenario: "multiple prologues in all projects", modifyFs: fs => { enableStrict(fs, sources[project.lib][source.config]); addTestPrologue(fs, sources[project.lib][source.ts][0], `"myPrologue"`); @@ -90,7 +87,7 @@ namespace ts { describe("Shebang", () => { // changes declaration because its emitted in .d.ts file verifyOutFileScenario({ - scenario: "shebang in all projects", + subScenario: "shebang in all projects", modifyFs: fs => { addShebang(fs, "lib", "file0"); addShebang(fs, "lib", "file1"); @@ -102,7 +99,7 @@ namespace ts { // emitHelpers describe("emitHelpers", () => { verifyOutFileScenario({ - scenario: "multiple emitHelpers in all projects", + subScenario: "multiple emitHelpers in all projects", modifyFs: fs => { addSpread(fs, "lib", "file0"); addRest(fs, "lib", "file1"); @@ -117,7 +114,7 @@ namespace ts { describe("triple slash refs", () => { // changes declaration because its emitted in .d.ts file verifyOutFileScenario({ - scenario: "triple slash refs in all projects", + subScenario: "triple slash refs in all projects", modifyFs: fs => { addTripleSlashRef(fs, "lib", "file0"); addTripleSlashRef(fs, "app", "file4"); @@ -161,7 +158,7 @@ ${internal} export enum internalEnum { a, b, c }`); // Verify initial + incremental edits verifyOutFileScenario({ - scenario: "stripInternal", + subScenario: "stripInternal", modifyFs: stripInternalScenario, modifyAgainFs: fs => replaceText(fs, sources[project.lib][source.ts][1], `export const`, `/*@internal*/ export const`), }); @@ -175,26 +172,13 @@ ${internal} export enum internalEnum { a, b, c }`); replaceText(fs, sources[project.app][source.ts][0], "file1", "lib/file1"); } - verifyTsbuildOutput({ - scenario: "when the module resolution finds original source file", - projFs: () => outFileFs, - time, - tick, - proj: "amdModulesWithOut", - rootNames: ["/src/app"], + verifyTsc({ + scenario: "amdModulesWithOut", + subScenario: "when the module resolution finds original source file", + fs: () => outFileFs, + commandLineArgs: ["-b", "/src/app", "--verbose"], + modifyFs, baselineSourceMap: true, - initialBuild: { - modifyFs, - expectedDiagnostics: [ - getExpectedDiagnosticForProjectsInBuild("src/lib/tsconfig.json", "src/app/tsconfig.json"), - [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/lib/tsconfig.json", "src/module.js"], - [Diagnostics.Building_project_0, sources[project.lib][source.config]], - [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/app/tsconfig.json", "src/app/module.js"], - [Diagnostics.Building_project_0, sources[project.app][source.config]], - ] - }, - baselineOnly: true, - verifyDiagnostics: true }); }); }); diff --git a/src/testRunner/unittests/tsbuild/containerOnlyReferenced.ts b/src/testRunner/unittests/tsbuild/containerOnlyReferenced.ts index 425dbf2e20f..f621d956621 100644 --- a/src/testRunner/unittests/tsbuild/containerOnlyReferenced.ts +++ b/src/testRunner/unittests/tsbuild/containerOnlyReferenced.ts @@ -19,7 +19,7 @@ namespace ts { it("verify that subsequent builds after initial build doesnt build anything", () => { const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); createSolutionBuilder(host, ["/src"], { verbose: true }).build(); host.assertDiagnosticMessages( getExpectedDiagnosticForProjectsInBuild("src/src/folder/tsconfig.json", "src/src/folder2/tsconfig.json", "src/src/tsconfig.json", "src/tests/tsconfig.json", "src/tsconfig.json"), diff --git a/src/testRunner/unittests/tsbuild/demo.ts b/src/testRunner/unittests/tsbuild/demo.ts index c345ad1e372..c8a597368ff 100644 --- a/src/testRunner/unittests/tsbuild/demo.ts +++ b/src/testRunner/unittests/tsbuild/demo.ts @@ -1,10 +1,8 @@ namespace ts { describe("unittests:: tsbuild:: on demo project", () => { let projFs: vfs.FileSystem; - const { time } = getTime(); - before(() => { - projFs = loadProjectFromDisk("tests/projects/demo", time); + projFs = loadProjectFromDisk("tests/projects/demo"); }); after(() => { @@ -49,7 +47,7 @@ namespace ts { function verifyBuild({ modifyDiskLayout, expectedExitStatus, expectedDiagnostics, expectedOutputs, notExpectedOutputs }: VerifyBuild) { const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); modifyDiskLayout(fs); const builder = createSolutionBuilder(host, ["/src/tsconfig.json"], { verbose: true }); const exitStatus = builder.build(); diff --git a/src/testRunner/unittests/tsbuild/emitDeclarationOnly.ts b/src/testRunner/unittests/tsbuild/emitDeclarationOnly.ts index e9ce4b46024..e7dff56ab9f 100644 --- a/src/testRunner/unittests/tsbuild/emitDeclarationOnly.ts +++ b/src/testRunner/unittests/tsbuild/emitDeclarationOnly.ts @@ -1,85 +1,53 @@ namespace ts { describe("unittests:: tsbuild:: on project with emitDeclarationOnly set to true", () => { let projFs: vfs.FileSystem; - const { time, tick } = getTime(); before(() => { - projFs = loadProjectFromDisk("tests/projects/emitDeclarationOnly", time); + projFs = loadProjectFromDisk("tests/projects/emitDeclarationOnly"); }); after(() => { projFs = undefined!; }); function verifyEmitDeclarationOnly(disableMap?: true) { - verifyTsbuildOutput({ - scenario: `only dts output in circular import project with emitDeclarationOnly${disableMap ? "" : " and declarationMap"}`, - projFs: () => projFs, - time, - tick, - proj: "emitDeclarationOnly", - rootNames: ["/src"], - initialBuild: { - modifyFs: disableMap ? - (fs => replaceText(fs, "/src/tsconfig.json", `"declarationMap": true,`, "")) : - noop, - expectedDiagnostics: [ - getExpectedDiagnosticForProjectsInBuild("src/tsconfig.json"), - [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/tsconfig.json", "src/lib/a.d.ts"], - [Diagnostics.Building_project_0, "/src/tsconfig.json"] - ] - }, - incrementalDtsChangedBuild: { + verifyTscIncrementalEdits({ + subScenario: `only dts output in circular import project with emitDeclarationOnly${disableMap ? "" : " and declarationMap"}`, + fs: () => projFs, + scenario: "emitDeclarationOnly", + commandLineArgs: ["--b", "/src", "--verbose"], + modifyFs: disableMap ? + (fs => replaceText(fs, "/src/tsconfig.json", `"declarationMap": true,`, "")) : + undefined, + incrementalScenarios: [{ + buildKind: BuildKind.IncrementalDtsChange, modifyFs: fs => replaceText(fs, "/src/src/a.ts", "b: B;", "b: B; foo: any;"), - expectedDiagnostics: [ - getExpectedDiagnosticForProjectsInBuild("src/tsconfig.json"), - [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tsconfig.json", "src/lib/a.d.ts", "src/src/a.ts"], - [Diagnostics.Building_project_0, "/src/tsconfig.json"] - ] - }, - baselineOnly: true, - verifyDiagnostics: true + }], }); } verifyEmitDeclarationOnly(); verifyEmitDeclarationOnly(/*disableMap*/ true); - verifyTsbuildOutput({ - scenario: `only dts output in non circular imports project with emitDeclarationOnly`, - projFs: () => projFs, - time, - tick, - proj: "emitDeclarationOnly", - rootNames: ["/src"], - initialBuild: { - modifyFs: fs => { - fs.rimrafSync("/src/src/index.ts"); - replaceText(fs, "/src/src/a.ts", `import { B } from "./b";`, `export class B { prop = "hello"; }`); + verifyTscIncrementalEdits({ + subScenario: `only dts output in non circular imports project with emitDeclarationOnly`, + fs: () => projFs, + scenario: "emitDeclarationOnly", + commandLineArgs: ["--b", "/src", "--verbose"], + modifyFs: fs => { + fs.rimrafSync("/src/src/index.ts"); + replaceText(fs, "/src/src/a.ts", `import { B } from "./b";`, `export class B { prop = "hello"; }`); + }, + incrementalScenarios: [ + { + buildKind: BuildKind.IncrementalDtsChange, + modifyFs: fs => replaceText(fs, "/src/src/a.ts", "b: B;", "b: B; foo: any;"), + }, - expectedDiagnostics: [ - getExpectedDiagnosticForProjectsInBuild("src/tsconfig.json"), - [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/tsconfig.json", "src/lib/a.d.ts"], - [Diagnostics.Building_project_0, "/src/tsconfig.json"] - ] - }, - incrementalDtsChangedBuild: { - modifyFs: fs => replaceText(fs, "/src/src/a.ts", "b: B;", "b: B; foo: any;"), - expectedDiagnostics: [ - getExpectedDiagnosticForProjectsInBuild("src/tsconfig.json"), - [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tsconfig.json", "src/lib/a.d.ts", "src/src/a.ts"], - [Diagnostics.Building_project_0, "/src/tsconfig.json"] - ] - }, - incrementalDtsUnchangedBuild: { - modifyFs: fs => replaceText(fs, "/src/src/a.ts", "export interface A {", `class C { } + { + buildKind: BuildKind.IncrementalDtsUnchanged, + modifyFs: fs => replaceText(fs, "/src/src/a.ts", "export interface A {", `class C { } export interface A {`), - expectedDiagnostics: [ - getExpectedDiagnosticForProjectsInBuild("src/tsconfig.json"), - [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tsconfig.json", "src/lib/a.d.ts", "src/src/a.ts"], - [Diagnostics.Building_project_0, "/src/tsconfig.json"], - [Diagnostics.Updating_unchanged_output_timestamps_of_project_0, "/src/tsconfig.json"] - ] - }, - baselineOnly: true, - verifyDiagnostics: true + + }, + ], }); }); } diff --git a/src/testRunner/unittests/tsbuild/emptyFiles.ts b/src/testRunner/unittests/tsbuild/emptyFiles.ts index a2e7aedf290..6e09b5871f9 100644 --- a/src/testRunner/unittests/tsbuild/emptyFiles.ts +++ b/src/testRunner/unittests/tsbuild/emptyFiles.ts @@ -10,7 +10,7 @@ namespace ts { describe("unittests:: tsbuild - empty files option in tsconfig", () => { it("has empty files diagnostic when files is empty and no references are provided", () => { const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/no-references"], { dry: false, force: false, verbose: false }); host.clearDiagnostics(); @@ -26,7 +26,7 @@ namespace ts { it("does not have empty files diagnostic when files is empty and references are provided", () => { const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/with-references"], { dry: false, force: false, verbose: false }); host.clearDiagnostics(); diff --git a/src/testRunner/unittests/tsbuild/graphOrdering.ts b/src/testRunner/unittests/tsbuild/graphOrdering.ts index d2fa94abd03..79ddd80d67b 100644 --- a/src/testRunner/unittests/tsbuild/graphOrdering.ts +++ b/src/testRunner/unittests/tsbuild/graphOrdering.ts @@ -17,7 +17,7 @@ namespace ts { before(() => { const fs = new vfs.FileSystem(false); - host = new fakes.SolutionBuilderHost(fs); + host = fakes.SolutionBuilderHost.create(fs); writeProjects(fs, ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"], deps); }); diff --git a/src/testRunner/unittests/tsbuild/helpers.ts b/src/testRunner/unittests/tsbuild/helpers.ts index 126b8d2f7d5..b21c60a8617 100644 --- a/src/testRunner/unittests/tsbuild/helpers.ts +++ b/src/testRunner/unittests/tsbuild/helpers.ts @@ -113,9 +113,11 @@ interface Symbol { } `; + /** + * Load project from disk into /src folder + */ export function loadProjectFromDisk( root: string, - time?: vfs.FileSystemOptions["time"], libContentToAppend?: string ): vfs.FileSystem { const resolver = vfs.createResolver(Harness.IO); @@ -125,22 +127,22 @@ interface Symbol { }, cwd: "/", meta: { defaultLibLocation: "/lib" }, - time }); addLibAndMakeReadonly(fs, libContentToAppend); return fs; } + /** + * All the files must be in /src + */ export function loadProjectFromFiles( files: vfs.FileSet, - time?: vfs.FileSystemOptions["time"], libContentToAppend?: string ): vfs.FileSystem { const fs = new vfs.FileSystem(/*ignoreCase*/ true, { files, cwd: "/", meta: { defaultLibLocation: "/lib" }, - time }); addLibAndMakeReadonly(fs, libContentToAppend); return fs; @@ -152,6 +154,26 @@ interface Symbol { fs.makeReadonly(); } + /** + * Gets the FS mountuing existing fs's /src and /lib folder + */ + export function getFsWithTime(baseFs: vfs.FileSystem) { + const { time, tick } = getTime(); + const host = new fakes.System(baseFs) as any as vfs.FileSystemResolverHost; + host.getWorkspaceRoot = notImplemented; + const resolver = vfs.createResolver(host); + const fs = new vfs.FileSystem(/*ignoreCase*/ true, { + files: { + ["/src"]: new vfs.Mount("/src", resolver), + ["/lib"]: new vfs.Mount("/lib", resolver) + }, + cwd: "/", + meta: { defaultLibLocation: "/lib" }, + time + }); + return { fs, time, tick }; + } + export function verifyOutputsPresent(fs: vfs.FileSystem, outputs: readonly string[]) { for (const output of outputs) { assert(fs.existsSync(output), `Expect file ${output} to exist`); @@ -164,7 +186,7 @@ interface Symbol { } } - function generateSourceMapBaselineFiles(fs: vfs.FileSystem, mapFileNames: Iterator) { + export function generateSourceMapBaselineFiles(fs: vfs.FileSystem, mapFileNames: Iterator) { while (true) { const { value: mapFile, done } = mapFileNames.next(); if (done) break; @@ -230,251 +252,117 @@ interface Symbol { } } - export interface BuildInput { - fs: vfs.FileSystem; - tick: () => void; - rootNames: readonly string[]; - modifyFs: (fs: vfs.FileSystem) => void; - baselineSourceMap?: true; - baselineBuildInfo?: true; - } - - export function tscBuild({ fs, tick, rootNames, modifyFs, baselineSourceMap, baselineBuildInfo }: BuildInput) { - const actualReadFileMap = createMap(); - modifyFs(fs); - tick(); - - const host = new fakes.SolutionBuilderHost(fs); - const writtenFiles = createMap(); - const originalWriteFile = host.writeFile; - host.writeFile = (fileName, content, writeByteOrderMark) => { - assert.isFalse(writtenFiles.has(fileName)); - writtenFiles.set(fileName, true); - return originalWriteFile.call(host, fileName, content, writeByteOrderMark); - }; - const builder = createSolutionBuilder(host, rootNames, { dry: false, force: false, verbose: true }); - host.clearDiagnostics(); - const originalReadFile = host.readFile; - host.readFile = path => { - // Dont record libs - if (path.startsWith("/src/")) { - actualReadFileMap.set(path, (actualReadFileMap.get(path) || 0) + 1); - } - return originalReadFile.call(host, path); - }; - builder.build(); - if (baselineSourceMap) generateSourceMapBaselineFiles(fs, mapDefinedIterator(writtenFiles.keys(), f => f.endsWith(".map") ? f : undefined)); - if (baselineBuildInfo) { - let expectedBuildInfoFiles: BuildInfoSectionBaselineFiles[] | undefined; - for (const { options } of builder.getAllParsedConfigs()) { - const out = options.outFile || options.out; - if (out) { - const { jsFilePath, declarationFilePath, buildInfoPath } = getOutputPathsForBundle(options, /*forceDts*/ false); - if (buildInfoPath && writtenFiles.has(buildInfoPath)) { - (expectedBuildInfoFiles || (expectedBuildInfoFiles = [])).push( - [buildInfoPath, jsFilePath, declarationFilePath] - ); - } + export function baselineBuildInfo( + configs: readonly ParsedCommandLine[], + fs: vfs.FileSystem, + writtenFiles: Map + ) { + let expectedBuildInfoFiles: BuildInfoSectionBaselineFiles[] | undefined; + for (const { options } of configs) { + const out = options.outFile || options.out; + if (out) { + const { jsFilePath, declarationFilePath, buildInfoPath } = getOutputPathsForBundle(options, /*forceDts*/ false); + if (buildInfoPath && writtenFiles.has(buildInfoPath)) { + (expectedBuildInfoFiles || (expectedBuildInfoFiles = [])).push( + [buildInfoPath, jsFilePath, declarationFilePath] + ); } } - if (expectedBuildInfoFiles) generateBuildInfoSectionBaselineFiles(fs, expectedBuildInfoFiles); } - fs.makeReadonly(); - return { fs, actualReadFileMap, host, builder, writtenFiles }; + if (expectedBuildInfoFiles) generateBuildInfoSectionBaselineFiles(fs, expectedBuildInfoFiles); } - function generateBaseline(fs: vfs.FileSystem, proj: string, scenario: string, subScenario: string, baseFs: vfs.FileSystem) { - const patch = fs.diff(baseFs, { includeChangedFileWithSameContent: true }); - // eslint-disable-next-line no-null/no-null - Harness.Baseline.runBaseline(`tsbuild/${proj}/${subScenario.split(" ").join("-")}/${scenario.split(" ").join("-")}.js`, patch ? vfs.formatPatch(patch) : null); - } - - function verifyReadFileCalls(actualReadFileMap: Map, expectedReadFiles: ReadonlyMap) { - TestFSWithWatch.verifyMapSize("readFileCalls", actualReadFileMap, arrayFrom(expectedReadFiles.keys())); - expectedReadFiles.forEach((expected, expectedFile) => { - const actual = actualReadFileMap.get(expectedFile); - assert.equal(actual, expected, `Mismatch in read file call number for: ${expectedFile} -Not in Actual: ${JSON.stringify(arrayFrom(mapDefinedIterator(expectedReadFiles.keys(), f => actualReadFileMap.has(f) ? undefined : f)))} -Mismatch Actual(path, actual, expected): ${JSON.stringify(arrayFrom(mapDefinedIterator(actualReadFileMap.entries(), ([p, v]) => expectedReadFiles.get(p) !== v ? [p, v, expectedReadFiles.get(p) || 0] : undefined)))}`); - }); - } - - export function getReadFilesMap(filesReadOnce: readonly string[], ...filesWithTwoReadCalls: string[]) { - const map = arrayToMap(filesReadOnce, identity, () => 1); - for (const fileWithTwoReadCalls of filesWithTwoReadCalls) { - map.set(fileWithTwoReadCalls, 2); - } - return map; - } - - export interface ExpectedBuildOutput { - expectedDiagnostics?: readonly fakes.ExpectedDiagnostic[]; - expectedReadFiles?: ReadonlyMap; - } - - export interface BuildState extends ExpectedBuildOutput { + export interface TscIncremental { + buildKind: BuildKind; modifyFs: (fs: vfs.FileSystem) => void; + subScenario?: string; } - export interface VerifyTsBuildInput { - scenario: string; - projFs: () => vfs.FileSystem; - time: () => number; - tick: () => void; - proj: string; - rootNames: readonly string[]; - initialBuild: BuildState; - incrementalDtsChangedBuild?: BuildState; - incrementalDtsUnchangedBuild?: BuildState; - incrementalHeaderChangedBuild?: BuildState; - baselineOnly?: true; - verifyDiagnostics?: true; - baselineSourceMap?: true; + export interface VerifyTsBuildInput extends TscCompile { + incrementalScenarios: TscIncremental[]; } - export function verifyTsbuildOutput({ - scenario, projFs, time, tick, proj, rootNames, - baselineOnly, verifyDiagnostics, baselineSourceMap, - initialBuild, incrementalDtsChangedBuild, incrementalDtsUnchangedBuild, incrementalHeaderChangedBuild + export function verifyTscIncrementalEdits({ + subScenario, fs, scenario, commandLineArgs, + baselineSourceMap, modifyFs, baselineReadFileCalls, + incrementalScenarios }: VerifyTsBuildInput) { - describe(`tsc --b ${proj}:: ${scenario}`, () => { - let fs: vfs.FileSystem; - let actualReadFileMap: Map; - let firstBuildTime: number; - let host: fakes.SolutionBuilderHost; - let initialWrittenFiles: Map; + describe(`tsc --b ${scenario}:: ${subScenario}`, () => { + let tick: () => void; + let sys: TscCompileSystem; before(() => { - const result = tscBuild({ - fs: projFs().shadow(), - tick, - rootNames, - modifyFs: initialBuild.modifyFs, + let baseFs: vfs.FileSystem; + ({ fs: baseFs, tick } = getFsWithTime(fs())); + sys = tscCompile({ + scenario, + subScenario, + fs: () => baseFs.makeReadonly(), + commandLineArgs, + modifyFs: fs => { + if (modifyFs) modifyFs(fs); + tick(); + }, baselineSourceMap, - baselineBuildInfo: true, + baselineReadFileCalls }); - ({ fs, actualReadFileMap, host, writtenFiles: initialWrittenFiles } = result); - firstBuildTime = time(); + Debug.assert(!!incrementalScenarios.length, `${scenario}/${subScenario}:: No incremental scenarios, you probably want to use verifyTsc instead.`); }); after(() => { - fs = undefined!; - actualReadFileMap = undefined!; - host = undefined!; - initialWrittenFiles = undefined!; + sys = undefined!; + tick = undefined!; }); describe("initialBuild", () => { - if (!baselineOnly || verifyDiagnostics) { - it(`verify diagnostics`, () => { - host.assertDiagnosticMessages(...(initialBuild.expectedDiagnostics || emptyArray)); - }); - } - it(`Generates files matching the baseline`, () => { - generateBaseline(fs, proj, scenario, "initial Build", projFs()); - }); - if (!baselineOnly) { - it("verify readFile calls", () => { - verifyReadFileCalls(actualReadFileMap, Debug.assertDefined(initialBuild.expectedReadFiles)); - }); - } + verifyTscBaseline(() => sys); }); - function incrementalBuild(subScenario: string, incrementalModifyFs: (fs: vfs.FileSystem) => void, incrementalExpectedDiagnostics: readonly fakes.ExpectedDiagnostic[] | undefined, incrementalExpectedReadFiles: ReadonlyMap | undefined) { - describe(subScenario, () => { - let newFs: vfs.FileSystem; - let actualReadFileMap: Map; - let host: fakes.SolutionBuilderHost; - let beforeBuildTime: number; - let afterBuildTime: number; + for (const { buildKind, modifyFs, subScenario: incrementalSubScenario } of incrementalScenarios) { + describe(incrementalSubScenario || buildKind, () => { + let newSys: TscCompileSystem; before(() => { - const lastProjectOutput = last(arrayFrom(initialWrittenFiles.keys())); - beforeBuildTime = fs.statSync(lastProjectOutput).mtimeMs; + Debug.assert(buildKind !== BuildKind.Initial, "Incremental edit cannot be initial compilation"); tick(); - newFs = fs.shadow(); - tick(); - ({ actualReadFileMap, host } = tscBuild({ - fs: newFs, - tick, - rootNames, - modifyFs: incrementalModifyFs, + newSys = tscCompile({ + scenario, + subScenario: incrementalSubScenario || subScenario, + buildKind, + fs: () => sys.vfs, + commandLineArgs, + modifyFs: fs => { + tick(); + modifyFs(fs); + tick(); + }, baselineSourceMap, - baselineBuildInfo: true, - })); - afterBuildTime = newFs.statSync(lastProjectOutput).mtimeMs; + baselineReadFileCalls + }); }); after(() => { - newFs = undefined!; - actualReadFileMap = undefined!; - host = undefined!; + newSys = undefined!; }); - it("verify build output times", () => { - assert.equal(beforeBuildTime, firstBuildTime, "First build timestamp is correct"); - assert.equal(afterBuildTime, time(), "Second build timestamp is correct"); - }); - if (!baselineOnly || verifyDiagnostics) { - it(`verify diagnostics`, () => { - host.assertDiagnosticMessages(...(incrementalExpectedDiagnostics || emptyArray)); - }); - } - else { - // Build should pass without errors if not verifying diagnostics - it(`verify no errors`, () => { - host.assertErrors(/*empty*/); - }); - } - it(`Generates files matching the baseline`, () => { - generateBaseline(newFs, proj, scenario, subScenario, fs); - }); - if (!baselineOnly) { - it("verify readFile calls", () => { - verifyReadFileCalls(actualReadFileMap, Debug.assertDefined(incrementalExpectedReadFiles)); - }); - } + verifyTscBaseline(() => newSys); it(`Verify emit output file text is same when built clean`, () => { - const { fs, writtenFiles } = tscBuild({ - fs: newFs.shadow(), - tick, - rootNames, + const sys = tscCompile({ + scenario, + subScenario, + fs: () => newSys.vfs, + commandLineArgs, modifyFs: fs => { + tick(); // Delete output files - const host = new fakes.SolutionBuilderHost(fs); - const builder = createSolutionBuilder(host, rootNames, { clean: true }); + const host = fakes.SolutionBuilderHost.create(fs); + const builder = createSolutionBuilder(host, commandLineArgs, { clean: true }); builder.clean(); }, }); - for (const outputFile of arrayFrom(writtenFiles.keys())) { - const expectedText = fs.existsSync(outputFile) ? fs.readFileSync(outputFile, "utf8") : undefined; - const actualText = newFs.existsSync(outputFile) ? newFs.readFileSync(outputFile, "utf8") : undefined; + for (const outputFile of arrayFrom(sys.writtenFiles.keys())) { + const expectedText = sys.readFile(outputFile); + const actualText = newSys.readFile(outputFile); assert.equal(actualText, expectedText, `File: ${outputFile}`); } }); }); } - if (incrementalDtsChangedBuild) { - incrementalBuild( - "incremental declaration changes", - incrementalDtsChangedBuild.modifyFs, - incrementalDtsChangedBuild.expectedDiagnostics, - incrementalDtsChangedBuild.expectedReadFiles, - ); - } - - if (incrementalDtsUnchangedBuild) { - incrementalBuild( - "incremental declaration doesnt change", - incrementalDtsUnchangedBuild.modifyFs, - incrementalDtsUnchangedBuild.expectedDiagnostics, - incrementalDtsUnchangedBuild.expectedReadFiles - ); - } - - if (incrementalHeaderChangedBuild) { - incrementalBuild( - "incremental headers change without dts changes", - incrementalHeaderChangedBuild.modifyFs, - incrementalHeaderChangedBuild.expectedDiagnostics, - incrementalHeaderChangedBuild.expectedReadFiles - ); - } }); } diff --git a/src/testRunner/unittests/tsbuild/inferredTypeFromTransitiveModule.ts b/src/testRunner/unittests/tsbuild/inferredTypeFromTransitiveModule.ts index 5383b7d32be..eb3658d14cc 100644 --- a/src/testRunner/unittests/tsbuild/inferredTypeFromTransitiveModule.ts +++ b/src/testRunner/unittests/tsbuild/inferredTypeFromTransitiveModule.ts @@ -1,82 +1,51 @@ namespace ts { describe("unittests:: tsbuild:: inferredTypeFromTransitiveModule::", () => { let projFs: vfs.FileSystem; - const { time, tick } = getTime(); before(() => { - projFs = loadProjectFromDisk("tests/projects/inferredTypeFromTransitiveModule", time); + projFs = loadProjectFromDisk("tests/projects/inferredTypeFromTransitiveModule"); }); after(() => { projFs = undefined!; }); - verifyTsbuildOutput({ - scenario: "inferred type from transitive module", - projFs: () => projFs, - time, - tick, - proj: "inferredTypeFromTransitiveModule", - rootNames: ["/src"], - initialBuild: { - modifyFs: noop, - expectedDiagnostics: [ - getExpectedDiagnosticForProjectsInBuild("src/tsconfig.json"), - [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/tsconfig.json", "src/obj/bar.js"], - [Diagnostics.Building_project_0, "/src/tsconfig.json"] - ] - }, - incrementalDtsChangedBuild: { + verifyTscIncrementalEdits({ + scenario: "inferredTypeFromTransitiveModule", + subScenario: "inferred type from transitive module", + fs: () => projFs, + commandLineArgs: ["--b", "/src", "--verbose"], + incrementalScenarios: [{ + buildKind: BuildKind.IncrementalDtsChange, modifyFs: changeBarParam, - expectedDiagnostics: [ - getExpectedDiagnosticForProjectsInBuild("src/tsconfig.json"), - [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tsconfig.json", "src/obj/bar.js", "src/bar.ts"], - [Diagnostics.Building_project_0, "/src/tsconfig.json"], - [Diagnostics.Updating_unchanged_output_timestamps_of_project_0, "/src/tsconfig.json"] - ] - }, - baselineOnly: true, - verifyDiagnostics: true + }], }); - verifyTsbuildOutput({ - scenario: "inferred type from transitive module with isolatedModules", - projFs: () => projFs, - time, - tick, - proj: "inferredTypeFromTransitiveModule", - rootNames: ["/src"], - initialBuild: { modifyFs: changeToIsolatedModules }, - incrementalDtsChangedBuild: { modifyFs: changeBarParam }, - baselineOnly: true, + verifyTscIncrementalEdits({ + subScenario: "inferred type from transitive module with isolatedModules", + fs: () => projFs, + scenario: "inferredTypeFromTransitiveModule", + commandLineArgs: ["--b", "/src", "--verbose"], + modifyFs: changeToIsolatedModules, + incrementalScenarios: [{ + buildKind: BuildKind.IncrementalDtsChange, + modifyFs: changeBarParam + }] }); - it("reports errors in files affected by change in signature", () => { - const { fs, host } = tscBuild({ - fs: projFs.shadow(), - tick, - rootNames: ["/src"], - modifyFs: fs => { - changeToIsolatedModules(fs); - appendText(fs, "/src/lazyIndex.ts", ` + verifyTscIncrementalEdits({ + scenario: "inferredTypeFromTransitiveModule", + subScenario: "reports errors in files affected by change in signature with isolatedModules", + fs: () => projFs, + commandLineArgs: ["--b", "/src", "--verbose"], + modifyFs: fs => { + changeToIsolatedModules(fs); + appendText(fs, "/src/lazyIndex.ts", ` import { default as bar } from './bar'; bar("hello");`); - } - }); - host.assertErrors(/*empty*/); - - tick(); - const { fs: newFs, host: newHost, writtenFiles } = tscBuild({ - fs: fs.shadow(), - tick, - rootNames: ["/src"], + }, + incrementalScenarios: [{ + buildKind: BuildKind.IncrementalDtsChange, modifyFs: changeBarParam - }); - // Has errors - newHost.assertErrors({ - message: [Diagnostics.Expected_0_arguments_but_got_1, 0, 1], - location: expectedLocationIndexOf(newFs, "/src/lazyIndex.ts", `"hello"`) - }); - // No written files - assert.equal(writtenFiles.size, 0); + }] }); }); diff --git a/src/testRunner/unittests/tsbuild/lateBoundSymbol.ts b/src/testRunner/unittests/tsbuild/lateBoundSymbol.ts index 02224b3fa88..f2cbfca320e 100644 --- a/src/testRunner/unittests/tsbuild/lateBoundSymbol.ts +++ b/src/testRunner/unittests/tsbuild/lateBoundSymbol.ts @@ -1,40 +1,22 @@ namespace ts { describe("unittests:: tsbuild:: lateBoundSymbol:: interface is merged and contains late bound member", () => { let projFs: vfs.FileSystem; - const { time, tick } = getTime(); before(() => { - projFs = loadProjectFromDisk("tests/projects/lateBoundSymbol", time); + projFs = loadProjectFromDisk("tests/projects/lateBoundSymbol"); }); after(() => { projFs = undefined!; // Release the contents }); - verifyTsbuildOutput({ - scenario: "interface is merged and contains late bound member", - projFs: () => projFs, - time, - tick, - proj: "lateBoundSymbol", - rootNames: ["/src/tsconfig.json"], - initialBuild: { - modifyFs: noop, - expectedDiagnostics: [ - getExpectedDiagnosticForProjectsInBuild("src/tsconfig.json"), - [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/tsconfig.json", "src/src/hkt.js"], - [Diagnostics.Building_project_0, "/src/tsconfig.json"] - ] - }, - incrementalDtsUnchangedBuild: { + verifyTscIncrementalEdits({ + subScenario: "interface is merged and contains late bound member", + fs: () => projFs, + scenario: "lateBoundSymbol", + commandLineArgs: ["--b", "/src/tsconfig.json", "--verbose"], + incrementalScenarios: [{ + buildKind: BuildKind.IncrementalDtsUnchanged, modifyFs: fs => replaceText(fs, "/src/src/main.ts", "const x = 10;", ""), - expectedDiagnostics: [ - getExpectedDiagnosticForProjectsInBuild("src/tsconfig.json"), - [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tsconfig.json", "src/src/hkt.js", "src/src/main.ts"], - [Diagnostics.Building_project_0, "/src/tsconfig.json"], - [Diagnostics.Updating_unchanged_output_timestamps_of_project_0, "/src/tsconfig.json"] - ] - }, - baselineOnly: true, - verifyDiagnostics: true + }] }); }); } diff --git a/src/testRunner/unittests/tsbuild/missingExtendedFile.ts b/src/testRunner/unittests/tsbuild/missingExtendedFile.ts index 907ed9202fa..7fa3352da26 100644 --- a/src/testRunner/unittests/tsbuild/missingExtendedFile.ts +++ b/src/testRunner/unittests/tsbuild/missingExtendedFile.ts @@ -3,7 +3,7 @@ namespace ts { it("unittests:: tsbuild - when tsconfig extends the missing file", () => { const projFs = loadProjectFromDisk("tests/projects/missingExtendedConfig"); const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/tsconfig.json"], {}); builder.build(); host.assertDiagnosticMessages( diff --git a/src/testRunner/unittests/tsbuild/moduleSpecifiers.ts b/src/testRunner/unittests/tsbuild/moduleSpecifiers.ts index 86328788a3b..81d8e170e5d 100644 --- a/src/testRunner/unittests/tsbuild/moduleSpecifiers.ts +++ b/src/testRunner/unittests/tsbuild/moduleSpecifiers.ts @@ -1,16 +1,16 @@ namespace ts { // https://github.com/microsoft/TypeScript/issues/31696 describe("unittests:: tsbuild:: moduleSpecifiers:: synthesized module specifiers to referenced projects resolve correctly", () => { - let projFs: vfs.FileSystem; - const { time, tick } = getTime(); - before(() => { - projFs = loadProjectFromFiles({ - "/src/common/nominal.ts": utils.dedent` + verifyTsc({ + scenario: "moduleSpecifiers", + subScenario: `synthesized module specifiers resolve correctly`, + fs: () => loadProjectFromFiles({ + "/src/solution/common/nominal.ts": utils.dedent` export declare type Nominal = T & { [Symbol.species]: Name; }; `, - "/src/common/tsconfig.json": utils.dedent` + "/src/solution/common/tsconfig.json": utils.dedent` { "extends": "../../tsconfig.base.json", "compilerOptions": { @@ -18,12 +18,12 @@ namespace ts { }, "include": ["nominal.ts"] }`, - "/src/sub-project/index.ts": utils.dedent` + "/src/solution/sub-project/index.ts": utils.dedent` import { Nominal } from '../common/nominal'; export type MyNominal = Nominal; `, - "/src/sub-project/tsconfig.json": utils.dedent` + "/src/solution/sub-project/tsconfig.json": utils.dedent` { "extends": "../../tsconfig.base.json", "compilerOptions": { @@ -34,7 +34,7 @@ namespace ts { ], "include": ["./index.ts"] }`, - "/src/sub-project-2/index.ts": utils.dedent` + "/src/solution/sub-project-2/index.ts": utils.dedent` import { MyNominal } from '../sub-project/index'; const variable = { @@ -45,7 +45,7 @@ namespace ts { return 'key'; } `, - "/src/sub-project-2/tsconfig.json": utils.dedent` + "/src/solution/sub-project-2/tsconfig.json": utils.dedent` { "extends": "../../tsconfig.base.json", "compilerOptions": { @@ -56,7 +56,7 @@ namespace ts { ], "include": ["./index.ts"] }`, - "/src/tsconfig.json": utils.dedent` + "/src/solution/tsconfig.json": utils.dedent` { "compilerOptions": { "composite": true @@ -67,7 +67,7 @@ namespace ts { ], "include": [] }`, - "/tsconfig.base.json": utils.dedent` + "/src/tsconfig.base.json": utils.dedent` { "compilerOptions": { "skipLibCheck": true, @@ -75,31 +75,17 @@ namespace ts { "outDir": "lib", } }`, - "/tsconfig.json": utils.dedent`{ + "/src/tsconfig.json": utils.dedent`{ "compilerOptions": { "composite": true }, "references": [ - { "path": "./src" } + { "path": "./solution" } ], "include": [] }` - }, time, symbolLibContent); - }); - after(() => { - projFs = undefined!; - }); - verifyTsbuildOutput({ - scenario: `synthesized module specifiers resolve correctly`, - projFs: () => projFs, - time, - tick, - proj: "moduleSpecifiers", - rootNames: ["/"], - initialBuild: { - modifyFs: noop, - }, - baselineOnly: true + }, symbolLibContent), + commandLineArgs: ["-b", "/src", "--verbose"] }); }); } diff --git a/src/testRunner/unittests/tsbuild/outFile.ts b/src/testRunner/unittests/tsbuild/outFile.ts index fa89e4a8ae9..20cbe05a3c1 100644 --- a/src/testRunner/unittests/tsbuild/outFile.ts +++ b/src/testRunner/unittests/tsbuild/outFile.ts @@ -56,7 +56,6 @@ namespace ts { ] ]; const relSources = sources.map(([config, sources]) => [relName(config), sources.map(relName)]) as any as [Sources, Sources, Sources]; - const { time, tick } = getTime(); let expectedOutputFiles = [ ...outputFiles[project.first], ...outputFiles[project.second], @@ -71,242 +70,78 @@ namespace ts { [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relSources[project.third][source.config], relOutputFiles[project.third][ext.js]], [Diagnostics.Building_project_0, sources[project.third][source.config]] ]; - let initialExpectedReadFiles: ReadonlyMap = getReadFilesMap( - [ - // Configs - sources[project.first][source.config], - sources[project.second][source.config], - sources[project.third][source.config], - - // Source files - ...sources[project.first][source.ts], - ...sources[project.second][source.ts], - ...sources[project.third][source.ts], - - // outputs - ...outputFiles[project.first], - ...outputFiles[project.second], - ] - ); - - let dtsChangedExpectedDiagnostics: readonly fakes.ExpectedDiagnostic[] = [ - getExpectedDiagnosticForProjectsInBuild(relSources[project.first][source.config], relSources[project.second][source.config], relSources[project.third][source.config]), - [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relSources[project.first][source.config], relOutputFiles[project.first][ext.js], relSources[project.first][source.ts][part.one]], - [Diagnostics.Building_project_0, sources[project.first][source.config]], - [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relSources[project.second][source.config], relSources[project.second][source.ts][part.one], relOutputFiles[project.second][ext.js]], - [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relSources[project.third][source.config], relOutputFiles[project.third][ext.js], "src/first"], - [Diagnostics.Building_project_0, sources[project.third][source.config]] - ]; - let dtsChangedExpectedReadFiles: ReadonlyMap = getReadFilesMap( - [ - // Configs - sources[project.first][source.config], - sources[project.second][source.config], - sources[project.third][source.config], - - // Source files - ...sources[project.first][source.ts], - ...sources[project.third][source.ts], - - // outputs - ...outputFiles[project.first], - ...outputFiles[project.second], - outputFiles[project.third][ext.dts], - ], - outputFiles[project.first][ext.dts], // dts changes so once read old content, and once new (to emit third) - ); - - let dtsChangedExpectedDiagnosticsDependOrdered: readonly fakes.ExpectedDiagnostic[] = [ - getExpectedDiagnosticForProjectsInBuild(relSources[project.first][source.config], relSources[project.second][source.config], relSources[project.third][source.config]), - [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relSources[project.first][source.config], relOutputFiles[project.first][ext.js], relSources[project.first][source.ts][part.one]], - [Diagnostics.Building_project_0, sources[project.first][source.config]], - [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relSources[project.second][source.config], relOutputFiles[project.second][ext.js], "src/first"], - [Diagnostics.Building_project_0, sources[project.second][source.config]], - [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relSources[project.third][source.config], relOutputFiles[project.third][ext.js], "src/second"], - [Diagnostics.Building_project_0, sources[project.third][source.config]] - ]; - let dtsChangedExpectedReadFilesDependOrdered: ReadonlyMap = getDtsChangedReadFilesDependOrdered(); - - let dtsUnchangedExpectedDiagnostics: readonly fakes.ExpectedDiagnostic[] = [ - getExpectedDiagnosticForProjectsInBuild(relSources[project.first][source.config], relSources[project.second][source.config], relSources[project.third][source.config]), - [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relSources[project.first][source.config], relOutputFiles[project.first][ext.js], relSources[project.first][source.ts][part.one]], - [Diagnostics.Building_project_0, sources[project.first][source.config]], - [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relSources[project.second][source.config], relSources[project.second][source.ts][part.one], relOutputFiles[project.second][ext.js]], - [Diagnostics.Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed, relSources[project.third][source.config], "src/first"], - [Diagnostics.Updating_output_of_project_0, sources[project.third][source.config]], - [Diagnostics.Updating_unchanged_output_timestamps_of_project_0, sources[project.third][source.config]], - ]; - let dtsUnchangedExpectedReadFiles: ReadonlyMap = getReadFilesMap( - [ - // Configs - sources[project.first][source.config], - sources[project.second][source.config], - sources[project.third][source.config], - - // Source files - ...sources[project.first][source.ts], - - // outputs to prepend - ...outputFiles[project.first], - ...outputFiles[project.second], - ...outputFiles[project.third], - ] - ); - - let dtsUnchangedExpectedDiagnosticsDependOrdered: readonly fakes.ExpectedDiagnostic[] = [ - getExpectedDiagnosticForProjectsInBuild(relSources[project.first][source.config], relSources[project.second][source.config], relSources[project.third][source.config]), - [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relSources[project.first][source.config], relOutputFiles[project.first][ext.js], relSources[project.first][source.ts][part.one]], - [Diagnostics.Building_project_0, sources[project.first][source.config]], - [Diagnostics.Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed, relSources[project.second][source.config], "src/first"], - [Diagnostics.Updating_output_of_project_0, sources[project.second][source.config]], - [Diagnostics.Updating_unchanged_output_timestamps_of_project_0, sources[project.second][source.config]], - [Diagnostics.Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed, relSources[project.third][source.config], "src/second"], - [Diagnostics.Updating_output_of_project_0, sources[project.third][source.config]], - [Diagnostics.Updating_unchanged_output_timestamps_of_project_0, sources[project.third][source.config]], - ]; - let dtsUnchangedExpectedReadFilesDependOrdered: ReadonlyMap = getDtsUnchangedExpectedReadFilesDependOrdered(); - before(() => { - outFileFs = loadProjectFromDisk("tests/projects/outfile-concat", time); + outFileFs = loadProjectFromDisk("tests/projects/outfile-concat"); }); after(() => { outFileFs = undefined!; expectedOutputFiles = undefined!; initialExpectedDiagnostics = undefined!; - initialExpectedReadFiles = undefined!; - dtsChangedExpectedDiagnostics = undefined!; - dtsChangedExpectedReadFiles = undefined!; - dtsChangedExpectedDiagnosticsDependOrdered = undefined!; - dtsChangedExpectedReadFilesDependOrdered = undefined!; - dtsUnchangedExpectedDiagnostics = undefined!; - dtsUnchangedExpectedReadFiles = undefined!; - dtsUnchangedExpectedDiagnosticsDependOrdered = undefined!; - dtsUnchangedExpectedReadFilesDependOrdered = undefined!; }); function createSolutionBuilder(host: fakes.SolutionBuilderHost, baseOptions?: BuildOptions) { return ts.createSolutionBuilder(host, ["/src/third"], { dry: false, force: false, verbose: true, ...(baseOptions || {}) }); } - function getInitialExpectedReadFiles(additionalSourceFiles?: readonly string[]) { - if (!additionalSourceFiles) return initialExpectedReadFiles; - const expectedReadFiles = cloneMap(initialExpectedReadFiles); - for (const path of additionalSourceFiles) { - expectedReadFiles.set(path, 1); - } - return expectedReadFiles; - } - - function getDtsChangedReadFilesDependOrdered() { - const value = cloneMap(dtsChangedExpectedReadFiles); - for (const path of sources[project.second][source.ts]) { - value.set(path, 1); - } - value.set(outputFiles[project.second][ext.dts], 2); // dts changes so once read old content, and once new (to emit third) - return value; - } - - function getDtsChangedReadFiles(dependOrdered?: boolean, additionalSourceFiles?: readonly string[]) { - const value = dependOrdered ? dtsChangedExpectedReadFilesDependOrdered : dtsChangedExpectedReadFiles; - if (!additionalSourceFiles) return value; - const expectedReadFiles = cloneMap(value); - for (const path of additionalSourceFiles) { - expectedReadFiles.set(path, 1); - } - return expectedReadFiles; - } - - function getDtsUnchangedExpectedReadFilesDependOrdered() { - const value = cloneMap(dtsUnchangedExpectedReadFiles); - // Since this changes too - for (const path of outputFiles[project.second]) { - value.set(path, 2); - } - return value; - } - - function getDtsUnchangedReadFiles(dependOrdered?: boolean, additionalSourceFiles?: readonly string[]) { - const value = dependOrdered ? dtsUnchangedExpectedReadFilesDependOrdered : dtsUnchangedExpectedReadFiles; - if (!additionalSourceFiles || additionalSourceFiles.length !== 3) return value; - const expectedReadFiles = cloneMap(value); - // Additional source Files - expectedReadFiles.set(additionalSourceFiles[project.first], 1); - return expectedReadFiles; - } - interface VerifyOutFileScenarioInput { - scenario: string; - modifyFs: (fs: vfs.FileSystem) => void; + subScenario: string; + modifyFs?: (fs: vfs.FileSystem) => void; modifyAgainFs?: (fs: vfs.FileSystem) => void; - additionalSourceFiles?: readonly string[]; - dependOrdered?: true; ignoreDtsChanged?: true; ignoreDtsUnchanged?: true; baselineOnly?: true; } function verifyOutFileScenario({ - scenario, + subScenario, modifyFs, modifyAgainFs, - additionalSourceFiles, - dependOrdered, ignoreDtsChanged, ignoreDtsUnchanged, baselineOnly }: VerifyOutFileScenarioInput) { - const initialExpectedReadFiles = !baselineOnly ? getInitialExpectedReadFiles(additionalSourceFiles) : undefined; - const dtsChangedReadFiles = !baselineOnly && !ignoreDtsChanged ? getDtsChangedReadFiles(dependOrdered, additionalSourceFiles) : undefined; - const dtsUnchanged: ExpectedBuildOutput | undefined = !baselineOnly && (!ignoreDtsUnchanged || !modifyAgainFs) ? { - expectedDiagnostics: dependOrdered ? - dtsUnchangedExpectedDiagnosticsDependOrdered : - dtsUnchangedExpectedDiagnostics, - expectedReadFiles: getDtsUnchangedReadFiles(dependOrdered, additionalSourceFiles) - } : undefined; - - verifyTsbuildOutput({ - scenario, - projFs: () => outFileFs, - time, - tick, - proj: "outfile-concat", - rootNames: ["/src/third"], - baselineSourceMap: true, - initialBuild: { - modifyFs, - expectedDiagnostics: initialExpectedDiagnostics, - expectedReadFiles: initialExpectedReadFiles - }, - incrementalDtsChangedBuild: !ignoreDtsChanged ? { + const incrementalScenarios: TscIncremental[] = []; + if (!ignoreDtsChanged) { + incrementalScenarios.push({ + buildKind: BuildKind.IncrementalDtsChange, modifyFs: fs => replaceText(fs, relSources[project.first][source.ts][part.one], "Hello", "Hola"), - expectedDiagnostics: dependOrdered ? - dtsChangedExpectedDiagnosticsDependOrdered : - dtsChangedExpectedDiagnostics, - expectedReadFiles: dtsChangedReadFiles - } : undefined, - incrementalDtsUnchangedBuild: !ignoreDtsUnchanged ? { + }); + } + if (!ignoreDtsUnchanged) { + incrementalScenarios.push({ + buildKind: BuildKind.IncrementalDtsUnchanged, modifyFs: fs => appendText(fs, relSources[project.first][source.ts][part.one], "console.log(s);"), - expectedDiagnostics: dtsUnchanged && dtsUnchanged.expectedDiagnostics, - expectedReadFiles: dtsUnchanged && dtsUnchanged.expectedReadFiles - } : undefined, - incrementalHeaderChangedBuild: modifyAgainFs ? { - modifyFs: modifyAgainFs, - expectedDiagnostics: dtsUnchanged && dtsUnchanged.expectedDiagnostics, - expectedReadFiles: dtsUnchanged && dtsUnchanged.expectedReadFiles - } : undefined, - baselineOnly - }); + }); + } + if (modifyAgainFs) { + incrementalScenarios.push({ + buildKind: BuildKind.IncrementalHeadersChange, + modifyFs: modifyAgainFs + }); + } + const input: VerifyTsBuildInput = { + subScenario, + fs: () => outFileFs, + scenario: "outfile-concat", + commandLineArgs: ["--b", "/src/third", "--verbose"], + baselineSourceMap: true, + modifyFs, + baselineReadFileCalls: !baselineOnly, + incrementalScenarios, + }; + return incrementalScenarios.length ? + verifyTscIncrementalEdits(input) : + verifyTsc(input); } // Verify initial + incremental edits verifyOutFileScenario({ - scenario: "baseline sectioned sourcemaps", - modifyFs: noop + subScenario: "baseline sectioned sourcemaps", }); // Verify baseline with build info + dts unChanged verifyOutFileScenario({ - scenario: "when final project is not composite but uses project references", + subScenario: "when final project is not composite but uses project references", modifyFs: fs => replaceText(fs, sources[project.third][source.config], `"composite": true,`, ""), ignoreDtsChanged: true, baselineOnly: true @@ -314,7 +149,7 @@ namespace ts { // Verify baseline with build info verifyOutFileScenario({ - scenario: "when final project is not composite but incremental", + subScenario: "when final project is not composite but incremental", modifyFs: fs => replaceText(fs, sources[project.third][source.config], `"composite": true,`, `"incremental": true,`), ignoreDtsChanged: true, ignoreDtsUnchanged: true, @@ -323,7 +158,7 @@ namespace ts { // Verify baseline with build info verifyOutFileScenario({ - scenario: "when final project specifies tsBuildInfoFile", + subScenario: "when final project specifies tsBuildInfoFile", modifyFs: fs => replaceText(fs, sources[project.third][source.config], `"composite": true,`, `"composite": true, "tsBuildInfoFile": "./thirdjs/output/third.tsbuildinfo",`), ignoreDtsChanged: true, @@ -338,7 +173,7 @@ namespace ts { ...outputFiles[project.second], ...outputFiles[project.third] ]; - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host); builder.build(); host.assertDiagnosticMessages(...initialExpectedDiagnostics); @@ -354,13 +189,13 @@ namespace ts { }); it("verify buildInfo absence results in new build", () => { - const fs = outFileFs.shadow(); + const { fs, tick } = getFsWithTime(outFileFs); const expectedOutputs = [ ...outputFiles[project.first], ...outputFiles[project.second], ...outputFiles[project.third] ]; - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); let builder = createSolutionBuilder(host); builder.build(); host.assertDiagnosticMessages(...initialExpectedDiagnostics); @@ -368,7 +203,11 @@ namespace ts { verifyOutputsPresent(fs, expectedOutputs); // Delete bundle info host.clearDiagnostics(); + + tick(); host.deleteFile(outputFiles[project.first][ext.buildinfo]); + tick(); + builder = createSolutionBuilder(host); builder.build(); host.assertDiagnosticMessages( @@ -384,7 +223,7 @@ namespace ts { it("verify that if incremental is set to false, tsbuildinfo is not generated", () => { const fs = outFileFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); replaceText(fs, sources[project.third][source.config], `"composite": true,`, ""); const builder = createSolutionBuilder(host); builder.build(); @@ -395,14 +234,16 @@ namespace ts { }); it("rebuilds completely when version in tsbuildinfo doesnt match ts version", () => { - const fs = outFileFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const { fs, tick } = getFsWithTime(outFileFs); + const host = fakes.SolutionBuilderHost.create(fs); let builder = createSolutionBuilder(host); builder.build(); host.assertDiagnosticMessages(...initialExpectedDiagnostics); host.clearDiagnostics(); + tick(); builder = createSolutionBuilder(host); changeCompilerVersion(host); + tick(); builder.build(); host.assertDiagnosticMessages( getExpectedDiagnosticForProjectsInBuild(relSources[project.first][source.config], relSources[project.second][source.config], relSources[project.third][source.config]), @@ -416,12 +257,12 @@ namespace ts { }); it("rebuilds completely when command line incremental flag changes between non dts changes", () => { - const fs = outFileFs.shadow(); + const { fs, tick } = getFsWithTime(outFileFs); // Make non composite third project replaceText(fs, sources[project.third][source.config], `"composite": true,`, ""); // Build with command line incremental - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); let builder = createSolutionBuilder(host, { incremental: true }); builder.build(); host.assertDiagnosticMessages(...initialExpectedDiagnostics); @@ -460,7 +301,7 @@ namespace ts { it("builds till project specified", () => { const fs = outFileFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, { verbose: false }); const result = builder.build(sources[project.second][source.config]); host.assertDiagnosticMessages(/*empty*/); @@ -473,7 +314,7 @@ namespace ts { it("cleans till project specified", () => { const fs = outFileFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, { verbose: false }); builder.build(); const result = builder.clean(sources[project.second][source.config]); @@ -490,7 +331,7 @@ namespace ts { describe("Prologues", () => { // Verify initial + incremental edits verifyOutFileScenario({ - scenario: "strict in all projects", + subScenario: "strict in all projects", modifyFs: fs => { enableStrict(fs, sources[project.first][source.config]); enableStrict(fs, sources[project.second][source.config]); @@ -501,7 +342,7 @@ namespace ts { // Verify ignore dtsChanged verifyOutFileScenario({ - scenario: "strict in one dependency", + subScenario: "strict in one dependency", modifyFs: fs => enableStrict(fs, sources[project.second][source.config]), modifyAgainFs: fs => addTestPrologue(fs, "src/first/first_PART1.ts", `"myPrologue"`), ignoreDtsChanged: true, @@ -510,7 +351,7 @@ namespace ts { // Verify initial + incremental edits - sourcemap verification verifyOutFileScenario({ - scenario: "multiple prologues in all projects", + subScenario: "multiple prologues in all projects", modifyFs: fs => { enableStrict(fs, sources[project.first][source.config]); addTestPrologue(fs, sources[project.first][source.ts][part.one], `"myPrologue"`); @@ -526,7 +367,7 @@ namespace ts { // Verify ignore dtsChanged verifyOutFileScenario({ - scenario: "multiple prologues in different projects", + subScenario: "multiple prologues in different projects", modifyFs: fs => { enableStrict(fs, sources[project.first][source.config]); addTestPrologue(fs, sources[project.second][source.ts][part.one], `"myPrologue"`); @@ -544,7 +385,7 @@ namespace ts { // changes declaration because its emitted in .d.ts file // Verify initial + incremental edits verifyOutFileScenario({ - scenario: "shebang in all projects", + subScenario: "shebang in all projects", modifyFs: fs => { addShebang(fs, "first", "first_PART1"); addShebang(fs, "first", "first_part2"); @@ -555,7 +396,7 @@ namespace ts { // Verify ignore dtsChanged verifyOutFileScenario({ - scenario: "shebang in only one dependency project", + subScenario: "shebang in only one dependency project", modifyFs: fs => addShebang(fs, "second", "second_part1"), ignoreDtsChanged: true, baselineOnly: true @@ -566,7 +407,7 @@ namespace ts { describe("emitHelpers", () => { // Verify initial + incremental edits verifyOutFileScenario({ - scenario: "emitHelpers in all projects", + subScenario: "emitHelpers in all projects", modifyFs: fs => { addRest(fs, "first", "first_PART1"); addRest(fs, "second", "second_part1"); @@ -577,7 +418,7 @@ namespace ts { // Verify ignore dtsChanged verifyOutFileScenario({ - scenario: "emitHelpers in only one dependency project", + subScenario: "emitHelpers in only one dependency project", modifyFs: fs => { addStubFoo(fs, "first", "first_PART1"); addRest(fs, "second", "second_part1"); @@ -589,7 +430,7 @@ namespace ts { // Verify ignore dtsChanged verifyOutFileScenario({ - scenario: "multiple emitHelpers in all projects", + subScenario: "multiple emitHelpers in all projects", modifyFs: fs => { addRest(fs, "first", "first_PART1"); addSpread(fs, "first", "first_part3"); @@ -605,7 +446,7 @@ namespace ts { // Verify ignore dtsChanged verifyOutFileScenario({ - scenario: "multiple emitHelpers in different projects", + subScenario: "multiple emitHelpers in different projects", modifyFs: fs => { addRest(fs, "first", "first_PART1"); addSpread(fs, "second", "second_part1"); @@ -622,24 +463,18 @@ namespace ts { // changes declaration because its emitted in .d.ts file // Verify initial + incremental edits verifyOutFileScenario({ - scenario: "triple slash refs in all projects", + subScenario: "triple slash refs in all projects", modifyFs: fs => { addTripleSlashRef(fs, "first", "first_part2"); addTripleSlashRef(fs, "second", "second_part1"); addTripleSlashRef(fs, "third", "third_part1"); - }, - additionalSourceFiles: [ - getTripleSlashRef("first"), getTripleSlashRef("second"), getTripleSlashRef("third") - ] + } }); // Verify ignore dtsChanged verifyOutFileScenario({ - scenario: "triple slash refs in one project", + subScenario: "triple slash refs in one project", modifyFs: fs => addTripleSlashRef(fs, "second", "second_part1"), - additionalSourceFiles: [ - getTripleSlashRef("second") - ], ignoreDtsChanged: true, baselineOnly: true }); @@ -698,14 +533,14 @@ ${internal} enum internalEnum { a, b, c }`); // Verify initial + incremental edits verifyOutFileScenario({ - scenario: "stripInternal", + subScenario: "stripInternal", modifyFs: stripInternalScenario, modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface"), }); // Verify ignore dtsChanged verifyOutFileScenario({ - scenario: "stripInternal with comments emit enabled", + subScenario: "stripInternal with comments emit enabled", modifyFs: fs => stripInternalScenario(fs, /*removeCommentsDisabled*/ true), modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface"), ignoreDtsChanged: true, @@ -714,7 +549,7 @@ ${internal} enum internalEnum { a, b, c }`); // Verify ignore dtsChanged verifyOutFileScenario({ - scenario: "stripInternal jsdoc style comment", + subScenario: "stripInternal jsdoc style comment", modifyFs: fs => stripInternalScenario(fs, /*removeCommentsDisabled*/ false, /*jsDocStyle*/ true), modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/**@internal*/ interface`, "interface"), ignoreDtsChanged: true, @@ -723,7 +558,7 @@ ${internal} enum internalEnum { a, b, c }`); // Verify ignore dtsChanged verifyOutFileScenario({ - scenario: "stripInternal jsdoc style with comments emit enabled", + subScenario: "stripInternal jsdoc style with comments emit enabled", modifyFs: fs => stripInternalScenario(fs, /*removeCommentsDisabled*/ true, /*jsDocStyle*/ true), ignoreDtsChanged: true, baselineOnly: true @@ -743,37 +578,33 @@ ${internal} enum internalEnum { a, b, c }`); // Verify initial + incremental edits verifyOutFileScenario({ - scenario: "stripInternal when one-two-three are prepended in order", + subScenario: "stripInternal when one-two-three are prepended in order", modifyFs: stripInternalWithDependentOrder, modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface"), - dependOrdered: true, }); // Verify ignore dtsChanged verifyOutFileScenario({ - scenario: "stripInternal with comments emit enabled when one-two-three are prepended in order", + subScenario: "stripInternal with comments emit enabled when one-two-three are prepended in order", modifyFs: fs => stripInternalWithDependentOrder(fs, /*removeCommentsDisabled*/ true), modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface"), - dependOrdered: true, ignoreDtsChanged: true, baselineOnly: true }); // Verify ignore dtsChanged verifyOutFileScenario({ - scenario: "stripInternal jsdoc style comment when one-two-three are prepended in order", + subScenario: "stripInternal jsdoc style comment when one-two-three are prepended in order", modifyFs: fs => stripInternalWithDependentOrder(fs, /*removeCommentsDisabled*/ false, /*jsDocStyle*/ true), modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/**@internal*/ interface`, "interface"), - dependOrdered: true, ignoreDtsChanged: true, baselineOnly: true }); // Verify ignore dtsChanged verifyOutFileScenario({ - scenario: "stripInternal jsdoc style with comments emit enabled when one-two-three are prepended in order", + subScenario: "stripInternal jsdoc style with comments emit enabled when one-two-three are prepended in order", modifyFs: fs => stripInternalWithDependentOrder(fs, /*removeCommentsDisabled*/ true, /*jsDocStyle*/ true), - dependOrdered: true, ignoreDtsChanged: true, baselineOnly: true }); @@ -781,7 +612,7 @@ ${internal} enum internalEnum { a, b, c }`); // only baseline verifyOutFileScenario({ - scenario: "stripInternal baseline when internal is inside another internal", + subScenario: "stripInternal baseline when internal is inside another internal", modifyFs: fs => { stripInternalOfThird(fs); prependText(fs, sources[project.first][source.ts][part.one], `namespace ts { @@ -820,7 +651,7 @@ ${internal} enum internalEnum { a, b, c }`); // only baseline verifyOutFileScenario({ - scenario: "stripInternal when few members of enum are internal", + subScenario: "stripInternal when few members of enum are internal", modifyFs: fs => { stripInternalOfThird(fs); prependText(fs, sources[project.first][source.ts][part.one], `enum TokenFlags { @@ -860,7 +691,7 @@ ${internal} enum internalEnum { a, b, c }`); // Verify ignore dtsChanged verifyOutFileScenario({ - scenario: "when source files are empty in the own file", + subScenario: "when source files are empty in the own file", modifyFs: makeThirdEmptySourceFile, ignoreDtsChanged: true, baselineOnly: true @@ -868,7 +699,7 @@ ${internal} enum internalEnum { a, b, c }`); // only baseline verifyOutFileScenario({ - scenario: "declarationMap and sourceMap disabled", + subScenario: "declarationMap and sourceMap disabled", modifyFs: fs => { makeThirdEmptySourceFile(fs); replaceText(fs, sources[project.third][source.config], `"composite": true,`, ""); @@ -898,7 +729,7 @@ ${internal} enum internalEnum { a, b, c }`); replaceText(fs, sources[project.second][source.config], `"outFile": "../2/second-output.js",`, ""); replaceText(fs, sources[project.third][source.config], `"outFile": "./thirdjs/output/third-output.js",`, ""); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host); builder.build(); host.assertDiagnosticMessages( diff --git a/src/testRunner/unittests/tsbuild/referencesWithRootDirInParent.ts b/src/testRunner/unittests/tsbuild/referencesWithRootDirInParent.ts index 79cc34ce016..d81e5f3f947 100644 --- a/src/testRunner/unittests/tsbuild/referencesWithRootDirInParent.ts +++ b/src/testRunner/unittests/tsbuild/referencesWithRootDirInParent.ts @@ -16,7 +16,7 @@ namespace ts { "/src/dist/main/b.js", "/src/dist/main/b.d.ts" ]; const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/src/main", "/src/src/other"], {}); builder.build(); host.assertDiagnosticMessages(/*empty*/); @@ -34,7 +34,7 @@ namespace ts { ]; const fs = projFs.shadow(); replaceText(fs, "/src/tsconfig.base.json", `"rootDir": "./src/",`, ""); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/src/main"], { verbose: true }); builder.build(); host.assertDiagnosticMessages( @@ -69,7 +69,7 @@ namespace ts { fs.writeFileSync("/src/src/other/tsconfig.json", JSON.stringify({ compilerOptions: { composite: true, outDir: "../../dist/" }, })); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/src/main"], { verbose: true }); builder.build(); host.assertDiagnosticMessages( @@ -105,7 +105,7 @@ namespace ts { fs.writeFileSync("/src/src/other/tsconfig.other.json", JSON.stringify({ compilerOptions: { composite: true, outDir: "../../dist/" }, })); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/src/main/tsconfig.main.json"], { verbose: true }); builder.build(); host.assertDiagnosticMessages( diff --git a/src/testRunner/unittests/tsbuild/resolveJsonModule.ts b/src/testRunner/unittests/tsbuild/resolveJsonModule.ts index f1ea08324f6..71ae0d4c86e 100644 --- a/src/testRunner/unittests/tsbuild/resolveJsonModule.ts +++ b/src/testRunner/unittests/tsbuild/resolveJsonModule.ts @@ -1,10 +1,9 @@ namespace ts { describe("unittests:: tsbuild:: with resolveJsonModule option on project resolveJsonModuleAndComposite", () => { let projFs: vfs.FileSystem; - const { time, tick } = getTime(); const allExpectedOutputs = ["/src/dist/src/index.js", "/src/dist/src/index.d.ts", "/src/dist/src/hello.json"]; before(() => { - projFs = loadProjectFromDisk("tests/projects/resolveJsonModuleAndComposite", time); + projFs = loadProjectFromDisk("tests/projects/resolveJsonModuleAndComposite"); }); after(() => { @@ -17,7 +16,7 @@ namespace ts { } function verifyProjectWithResolveJsonModuleWithFs(fs: vfs.FileSystem, configFile: string, allExpectedOutputs: readonly string[], ...expectedDiagnosticMessages: fakes.ExpectedDiagnostic[]) { - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, [configFile], { dry: false, force: false, verbose: false }); builder.build(); host.assertDiagnosticMessages(...expectedDiagnosticMessages); @@ -65,10 +64,10 @@ export default hello.hello`); }); it("with resolveJsonModule and sourceMap", () => { - const fs = projFs.shadow(); + const { fs, tick } = getFsWithTime(projFs); const configFile = "src/tsconfig_withFiles.json"; replaceText(fs, configFile, `"composite": true,`, `"composite": true, "sourceMap": true,`); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); let builder = createSolutionBuilder(host, [configFile], { verbose: true }); builder.build(); host.assertDiagnosticMessages( @@ -88,10 +87,10 @@ export default hello.hello`); }); it("with resolveJsonModule and without outDir", () => { - const fs = projFs.shadow(); + const { fs, tick } = getFsWithTime(projFs); const configFile = "src/tsconfig_withFiles.json"; replaceText(fs, configFile, `"outDir": "dist",`, ""); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); let builder = createSolutionBuilder(host, [configFile], { verbose: true }); builder.build(); host.assertDiagnosticMessages( @@ -112,10 +111,9 @@ export default hello.hello`); }); describe("unittests:: tsbuild:: with resolveJsonModule option on project importJsonFromProjectReference", () => { - const { time, tick } = getTime(); let projFs: vfs.FileSystem; before(() => { - projFs = loadProjectFromDisk("tests/projects/importJsonFromProjectReference", time); + projFs = loadProjectFromDisk("tests/projects/importJsonFromProjectReference"); }); after(() => { @@ -124,11 +122,11 @@ export default hello.hello`); it("when importing json module from project reference", () => { const expectedOutput = "/src/main/index.js"; - const fs = projFs.shadow(); + const { fs, tick } = getFsWithTime(projFs); const configFile = "src/tsconfig.json"; const stringsConfigFile = "src/strings/tsconfig.json"; const mainConfigFile = "src/main/tsconfig.json"; - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); let builder = createSolutionBuilder(host, [configFile], { verbose: true }); builder.build(); host.assertDiagnosticMessages( diff --git a/src/testRunner/unittests/tsbuild/sample.ts b/src/testRunner/unittests/tsbuild/sample.ts index d95ba5e514a..1a27a624197 100644 --- a/src/testRunner/unittests/tsbuild/sample.ts +++ b/src/testRunner/unittests/tsbuild/sample.ts @@ -1,14 +1,13 @@ namespace ts { describe("unittests:: tsbuild:: on 'sample1' project", () => { let projFs: vfs.FileSystem; - const { time, tick } = getTime(); const testsOutputs = ["/src/tests/index.js", "/src/tests/index.d.ts", "/src/tests/tsconfig.tsbuildinfo"]; const logicOutputs = ["/src/logic/index.js", "/src/logic/index.js.map", "/src/logic/index.d.ts", "/src/logic/tsconfig.tsbuildinfo"]; const coreOutputs = ["/src/core/index.js", "/src/core/index.d.ts", "/src/core/index.d.ts.map", "/src/core/tsconfig.tsbuildinfo"]; const allExpectedOutputs = [...testsOutputs, ...logicOutputs, ...coreOutputs]; before(() => { - projFs = loadProjectFromDisk("tests/projects/sample1", time); + projFs = loadProjectFromDisk("tests/projects/sample1"); }); after(() => { @@ -18,7 +17,7 @@ namespace ts { describe("sanity check of clean build of 'sample1' project", () => { it("can build the sample project 'sample1' without error", () => { const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/tests"], { dry: false, force: false, verbose: false }); host.clearDiagnostics(); @@ -36,7 +35,7 @@ namespace ts { references: [{ path: "../core" }] })); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/tests"], {}); builder.build(); host.assertDiagnosticMessages(/*empty*/); @@ -52,7 +51,7 @@ namespace ts { references: [{ path: "../core" }] })); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/tests"], {}); builder.build(); host.assertDiagnosticMessages(/*empty*/); @@ -64,7 +63,7 @@ namespace ts { it("builds correctly when project is not composite or doesnt have any references", () => { const fs = projFs.shadow(); replaceText(fs, "/src/core/tsconfig.json", `"composite": true,`, ""); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/core"], { verbose: true }); builder.build(); host.assertDiagnosticMessages( @@ -79,7 +78,7 @@ namespace ts { describe("dry builds", () => { it("doesn't write any files in a dry build", () => { const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/tests"], { dry: true, force: false, verbose: false }); builder.build(); host.assertDiagnosticMessages( @@ -93,8 +92,8 @@ namespace ts { }); it("indicates that it would skip builds during a dry build", () => { - const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const { fs, tick } = getFsWithTime(projFs); + const host = fakes.SolutionBuilderHost.create(fs); let builder = createSolutionBuilder(host, ["/src/tests"], { dry: false, force: false, verbose: false }); builder.build(); @@ -114,7 +113,7 @@ namespace ts { describe("clean builds", () => { it("removes all files it built", () => { const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/tests"], { dry: false, force: false, verbose: false }); builder.build(); @@ -136,7 +135,7 @@ namespace ts { it("cleans till project specified", () => { const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/tests"], {}); builder.build(); const result = builder.clean("/src/logic"); @@ -148,7 +147,7 @@ namespace ts { it("cleaning project in not build order doesnt throw error", () => { const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/tests"], {}); builder.build(); const result = builder.clean("/src/logic2"); @@ -160,8 +159,8 @@ namespace ts { describe("force builds", () => { it("always builds under --force", () => { - const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const { fs, time, tick } = getFsWithTime(projFs); + const host = fakes.SolutionBuilderHost.create(fs); let builder = createSolutionBuilder(host, ["/src/tests"], { dry: false, force: true, verbose: false }); builder.build(); @@ -187,8 +186,8 @@ namespace ts { describe("can detect when and what to rebuild", () => { function initializeWithBuild(opts?: BuildOptions) { - const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const { fs, tick } = getFsWithTime(projFs); + const host = fakes.SolutionBuilderHost.create(fs); let builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true }); builder.build(); host.clearDiagnostics(); @@ -199,7 +198,7 @@ namespace ts { it("Builds the project", () => { const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true }); builder.build(); host.assertDiagnosticMessages( @@ -273,8 +272,8 @@ namespace ts { }); it("does not rebuild if there is no program and bundle in the ts build info event if version doesnt match ts version", () => { - const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs, /*options*/ undefined, /*setParentNodes*/ undefined, createAbstractBuilder); + const { fs, tick } = getFsWithTime(projFs); + const host = fakes.SolutionBuilderHost.create(fs, /*options*/ undefined, /*setParentNodes*/ undefined, createAbstractBuilder); let builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true }); builder.build(); host.assertDiagnosticMessages( @@ -329,10 +328,10 @@ namespace ts { }); it("rebuilds when extended config file changes", () => { - const fs = projFs.shadow(); + const { fs, tick } = getFsWithTime(projFs); 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 host = fakes.SolutionBuilderHost.create(fs); let builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true }); builder.build(); host.assertDiagnosticMessages( @@ -360,7 +359,7 @@ namespace ts { it("builds till project specified", () => { const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/tests"], {}); const result = builder.build("/src/logic"); host.assertDiagnosticMessages(/*empty*/); @@ -371,7 +370,7 @@ namespace ts { it("building project in not build order doesnt throw error", () => { const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/tests"], {}); const result = builder.build("/src/logic2"); host.assertDiagnosticMessages(/*empty*/); @@ -386,7 +385,7 @@ namespace ts { } const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/tests"], {}); verifyBuildNextResult({ project: "/src/core/tsconfig.json" as ResolvedConfigFileName, @@ -420,7 +419,7 @@ namespace ts { it("building using buildReferencedProject", () => { const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true }); builder.buildReferences("/src/tests"); host.assertDiagnosticMessages( @@ -438,7 +437,7 @@ namespace ts { describe("downstream-blocked compilations", () => { it("won't build downstream projects if upstream projects have errors", () => { const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/tests"], { dry: false, force: false, verbose: true }); // Induce an error in the middle project @@ -462,8 +461,8 @@ namespace ts { describe("project invalidation", () => { it("invalidates projects correctly", () => { - const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const { fs, time, tick } = getFsWithTime(projFs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/tests"], { dry: false, force: false, verbose: false }); builder.build(); @@ -518,7 +517,7 @@ export class cNew {}`); describe("lists files", () => { it("listFiles", () => { const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/tests"], { listFiles: true }); builder.build(); assert.deepEqual(host.traces, [ @@ -545,7 +544,7 @@ export class cNew {}`); it("listEmittedFiles", () => { const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); const builder = createSolutionBuilder(host, ["/src/tests"], { listEmittedFiles: true }); builder.build(); assert.deepEqual(host.traces, [ @@ -568,266 +567,73 @@ export class cNew {}`); }); describe("emit output", () => { - const initialBuild: BuildState = { - modifyFs: noop, - expectedDiagnostics: [ - 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"] - ], - expectedReadFiles: getReadFilesMap( - [ - // Configs - "/src/core/tsconfig.json", - "/src/logic/tsconfig.json", - "/src/tests/tsconfig.json", - - // Source files - "/src/core/anotherModule.ts", - "/src/core/index.ts", - "/src/core/some_decl.d.ts", - "/src/logic/index.ts", - "/src/tests/index.ts", - - // Modules of generated files - "/src/core/anotherModule.d.ts", - "/src/core/index.d.ts", - "/src/logic/index.d.ts", - - // build info - "/src/core/tsconfig.tsbuildinfo", - "/src/logic/tsconfig.tsbuildinfo", - "/src/tests/tsconfig.tsbuildinfo" - ] - ) - }; - verifyTsbuildOutput({ - scenario: "sample", - projFs: () => projFs, - time, - tick, - proj: "sample1", - rootNames: ["/src/tests"], + verifyTscIncrementalEdits({ + subScenario: "sample", + fs: () => projFs, + scenario: "sample1", + commandLineArgs: ["--b", "/src/tests", "--verbose"], baselineSourceMap: true, - initialBuild, - incrementalDtsChangedBuild: { - modifyFs: fs => appendText(fs, "/src/core/index.ts", ` + baselineReadFileCalls: true, + incrementalScenarios: [ + { + buildKind: BuildKind.IncrementalDtsChange, + modifyFs: fs => appendText(fs, "/src/core/index.ts", ` export class someClass { }`), - expectedDiagnostics: [ - // Emits only partial core instead of all outputs - getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"), - [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/core/tsconfig.json", "src/core/anotherModule.js", "src/core/index.ts"], - [Diagnostics.Building_project_0, "/src/core/tsconfig.json"], - [Diagnostics.Updating_unchanged_output_timestamps_of_project_0, "/src/core/tsconfig.json"], - [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/logic/tsconfig.json", "src/logic/index.js", "src/core"], - [Diagnostics.Building_project_0, "/src/logic/tsconfig.json"], - [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/core"], - [Diagnostics.Building_project_0, "/src/tests/tsconfig.json"], - ], - expectedReadFiles: getReadFilesMap( - [ - // Configs - "/src/core/tsconfig.json", - "/src/logic/tsconfig.json", - "/src/tests/tsconfig.json", - - // Source files - "/src/core/anotherModule.ts", - "/src/core/index.ts", - "/src/core/some_decl.d.ts", - "/src/logic/index.ts", - "/src/tests/index.ts", - - // Modules of generated files - "/src/core/anotherModule.d.ts", - "/src/core/index.d.ts", - "/src/logic/index.d.ts", - - // build info - "/src/core/tsconfig.tsbuildinfo", - "/src/logic/tsconfig.tsbuildinfo", - "/src/tests/tsconfig.tsbuildinfo", - - "/src/tests/index.d.ts", // to check if d.ts has changed - ], - "/src/core/index.d.ts", // to check if changed, and to build other projects after change - ), - }, - incrementalDtsUnchangedBuild: { - modifyFs: fs => appendText(fs, "/src/core/index.ts", ` + }, + { + buildKind: BuildKind.IncrementalDtsUnchanged, + modifyFs: fs => appendText(fs, "/src/core/index.ts", ` class someClass { }`), - expectedDiagnostics: [ - getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"), - [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/core/tsconfig.json", "src/core/anotherModule.js", "src/core/index.ts"], - [Diagnostics.Building_project_0, "/src/core/tsconfig.json"], - [Diagnostics.Updating_unchanged_output_timestamps_of_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.Updating_output_timestamps_of_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.Updating_output_timestamps_of_project_0, "/src/tests/tsconfig.json"] - ], - expectedReadFiles: getReadFilesMap( - [ - // Configs - "/src/core/tsconfig.json", - "/src/logic/tsconfig.json", - "/src/tests/tsconfig.json", - - // Source files - "/src/core/anotherModule.ts", - "/src/core/index.ts", - "/src/core/some_decl.d.ts", - - // to check if changed - "/src/core/index.d.ts", - - // build info - "/src/core/tsconfig.tsbuildinfo", - "/src/logic/tsconfig.tsbuildinfo", - "/src/tests/tsconfig.tsbuildinfo", - ], - ) - }, - }); - - verifyTsbuildOutput({ - scenario: "when logic config changes declaration dir", - projFs: () => projFs, - time, - tick, - proj: "sample1", - rootNames: ["/src/tests"], - baselineSourceMap: true, - initialBuild, - incrementalDtsChangedBuild: { - modifyFs: fs => replaceText(fs, "/src/logic/tsconfig.json", `"declaration": true,`, `"declaration": true, + }, + { + subScenario: "when logic config changes declaration dir", + buildKind: BuildKind.IncrementalDtsChange, + modifyFs: fs => replaceText(fs, "/src/logic/tsconfig.json", `"declaration": true,`, `"declaration": true, "declarationDir": "decls",`), - expectedDiagnostics: [ - 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_out_of_date_because_output_file_1_does_not_exist, "src/logic/tsconfig.json", "src/logic/decls/index.d.ts"], - [Diagnostics.Building_project_0, "/src/logic/tsconfig.json"], - [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/logic"], - [Diagnostics.Building_project_0, "/src/tests/tsconfig.json"], - ], - expectedReadFiles: getReadFilesMap( - [ - // Configs - "/src/core/tsconfig.json", - "/src/logic/tsconfig.json", - "/src/tests/tsconfig.json", - - // Source files - "/src/logic/index.ts", - "/src/tests/index.ts", - - // Modules of generated files - "/src/core/anotherModule.d.ts", - "/src/core/index.d.ts", - "/src/logic/decls/index.d.ts", - - // build info - "/src/core/tsconfig.tsbuildinfo", - "/src/logic/tsconfig.tsbuildinfo", - "/src/tests/tsconfig.tsbuildinfo", - - "/src/tests/index.d.ts", // to check if d.ts has changed - ] - ) - }, + } + ], }); - verifyTsbuildOutput({ - scenario: "when logic specifies tsBuildInfoFile", - projFs: () => projFs, - time, - tick, - proj: "sample1", - rootNames: ["/src/tests"], - baselineSourceMap: true, - initialBuild: { - modifyFs: fs => replaceText(fs, "/src/logic/tsconfig.json", `"composite": true,`, `"composite": true, + verifyTsc({ + scenario: "sample1", + subScenario: "when logic specifies tsBuildInfoFile", + fs: () => projFs, + modifyFs: fs => replaceText(fs, "/src/logic/tsconfig.json", `"composite": true,`, `"composite": true, "tsBuildInfoFile": "ownFile.tsbuildinfo",`), - expectedDiagnostics: initialBuild.expectedDiagnostics, - expectedReadFiles: getReadFilesMap( - [ - // Configs - "/src/core/tsconfig.json", - "/src/logic/tsconfig.json", - "/src/tests/tsconfig.json", - - // Source files - "/src/core/anotherModule.ts", - "/src/core/index.ts", - "/src/core/some_decl.d.ts", - "/src/logic/index.ts", - "/src/tests/index.ts", - - // Modules of generated files - "/src/core/anotherModule.d.ts", - "/src/core/index.d.ts", - "/src/logic/index.d.ts", - - // build info - "/src/core/tsconfig.tsbuildinfo", - "/src/logic/ownFile.tsbuildinfo", - "/src/tests/tsconfig.tsbuildinfo" - ] - ) - }, + commandLineArgs: ["--b", "/src/tests", "--verbose"], + baselineSourceMap: true, + baselineReadFileCalls: true }); - verifyTsbuildOutput({ - scenario: "when declaration option changes", - projFs: () => projFs, - time, - tick, - proj: "sample1", - rootNames: ["/src/core"], - initialBuild: { - modifyFs: fs => fs.writeFileSync("/src/core/tsconfig.json", `{ + verifyTscIncrementalEdits({ + subScenario: "when declaration option changes", + fs: () => projFs, + scenario: "sample1", + commandLineArgs: ["--b", "/src/core", "--verbose"], + modifyFs: fs => fs.writeFileSync("/src/core/tsconfig.json", `{ "compilerOptions": { "incremental": true, "skipDefaultLibCheck": true } }`), - expectedDiagnostics: [ - getExpectedDiagnosticForProjectsInBuild("src/core/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"], - ] - }, - incrementalDtsChangedBuild: { + incrementalScenarios: [{ + buildKind: BuildKind.IncrementalDtsChange, modifyFs: fs => replaceText(fs, "/src/core/tsconfig.json", `"incremental": true,`, `"incremental": true, "declaration": true,`), - expectedDiagnostics: [ - getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json"), - [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/core/tsconfig.json", "src/core/anotherModule.d.ts"], - [Diagnostics.Building_project_0, "/src/core/tsconfig.json"] - ] - }, - baselineOnly: true, - verifyDiagnostics: true + }], }); - verifyTsbuildOutput({ - scenario: "when target option changes", - projFs: () => projFs, - time, - tick, - proj: "sample1", - rootNames: ["/src/core"], - initialBuild: { - modifyFs: fs => { - fs.writeFileSync("/lib/lib.esnext.full.d.ts", `/// + verifyTscIncrementalEdits({ + subScenario: "when target option changes", + fs: () => projFs, + scenario: "sample1", + commandLineArgs: ["--b", "/src/core", "--verbose"], + modifyFs: fs => { + fs.writeFileSync("/lib/lib.esnext.full.d.ts", `/// /// `); - fs.writeFileSync("/lib/lib.esnext.d.ts", libContent); - fs.writeFileSync("/lib/lib.d.ts", `/// + fs.writeFileSync("/lib/lib.esnext.d.ts", libContent); + fs.writeFileSync("/lib/lib.d.ts", `/// /// `); - fs.writeFileSync("/src/core/tsconfig.json", `{ + fs.writeFileSync("/src/core/tsconfig.json", `{ "compilerOptions": { "incremental": true, "listFiles": true, @@ -835,66 +641,36 @@ class someClass { }`), "target": "esnext", } }`); - }, - expectedDiagnostics: [ - getExpectedDiagnosticForProjectsInBuild("src/core/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"], - ] }, - incrementalDtsChangedBuild: { + incrementalScenarios: [{ + buildKind: BuildKind.IncrementalDtsChange, modifyFs: fs => replaceText(fs, "/src/core/tsconfig.json", "esnext", "es5"), - expectedDiagnostics: [ - getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json"), - [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/core/tsconfig.json", "src/core/anotherModule.js", "src/core/tsconfig.json"], - [Diagnostics.Building_project_0, "/src/core/tsconfig.json"] - ] - }, - baselineOnly: true, - verifyDiagnostics: true + }], }); - verifyTsbuildOutput({ - scenario: "when module option changes", - projFs: () => projFs, - time, - tick, - proj: "sample1", - rootNames: ["/src/core"], - initialBuild: { - modifyFs: fs => fs.writeFileSync("/src/core/tsconfig.json", `{ + verifyTscIncrementalEdits({ + subScenario: "when module option changes", + fs: () => projFs, + scenario: "sample1", + commandLineArgs: ["--b", "/src/core", "--verbose"], + modifyFs: fs => fs.writeFileSync("/src/core/tsconfig.json", `{ "compilerOptions": { "incremental": true, "module": "commonjs" } }`), - expectedDiagnostics: [ - getExpectedDiagnosticForProjectsInBuild("src/core/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"], - ] - }, - incrementalDtsChangedBuild: { + incrementalScenarios: [{ + buildKind: BuildKind.IncrementalDtsChange, modifyFs: fs => replaceText(fs, "/src/core/tsconfig.json", `"module": "commonjs"`, `"module": "amd"`), - expectedDiagnostics: [ - getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json"), - [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/core/tsconfig.json", "src/core/anotherModule.js", "src/core/tsconfig.json"], - [Diagnostics.Building_project_0, "/src/core/tsconfig.json"] - ] - }, - baselineOnly: true, - verifyDiagnostics: true + }], }); - verifyTsbuildOutput({ - scenario: "when esModuleInterop option changes", - projFs: () => projFs, - time, - tick, - proj: "sample1", - rootNames: ["/src/tests"], - initialBuild: { - modifyFs: fs => fs.writeFileSync("/src/tests/tsconfig.json", `{ + verifyTscIncrementalEdits({ + subScenario: "when esModuleInterop option changes", + fs: () => projFs, + scenario: "sample1", + commandLineArgs: ["--b", "/src/tests", "--verbose"], + modifyFs: fs => fs.writeFileSync("/src/tests/tsconfig.json", `{ "references": [ { "path": "../core" }, { "path": "../logic" } @@ -908,28 +684,10 @@ class someClass { }`), "esModuleInterop": false } }`), - expectedDiagnostics: [ - 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"] - ] - }, - incrementalDtsChangedBuild: { + incrementalScenarios: [{ + buildKind: BuildKind.IncrementalDtsChange, modifyFs: fs => replaceText(fs, "/src/tests/tsconfig.json", `"esModuleInterop": false`, `"esModuleInterop": true`), - expectedDiagnostics: [ - 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"] - ] - }, - baselineOnly: true, - verifyDiagnostics: true + }], }); }); }); diff --git a/src/testRunner/unittests/tsbuild/transitiveReferences.ts b/src/testRunner/unittests/tsbuild/transitiveReferences.ts index d661ba0c798..99fcd75d087 100644 --- a/src/testRunner/unittests/tsbuild/transitiveReferences.ts +++ b/src/testRunner/unittests/tsbuild/transitiveReferences.ts @@ -27,7 +27,7 @@ namespace ts { function verifyBuild(modifyDiskLayout: (fs: vfs.FileSystem) => void, allExpectedOutputs: readonly string[], expectedFileTraces: readonly string[], ...expectedDiagnostics: fakes.ExpectedDiagnostic[]) { const fs = projFs.shadow(); - const host = new fakes.SolutionBuilderHost(fs); + const host = fakes.SolutionBuilderHost.create(fs); modifyDiskLayout(fs); const builder = createSolutionBuilder(host, ["/src/tsconfig.c.json"], { listFiles: true }); builder.build(); diff --git a/src/testRunner/unittests/tsbuild/watchMode.ts b/src/testRunner/unittests/tsbuild/watchMode.ts index bc5cd79f7ef..b2f2eac1582 100644 --- a/src/testRunner/unittests/tsbuild/watchMode.ts +++ b/src/testRunner/unittests/tsbuild/watchMode.ts @@ -2,18 +2,12 @@ namespace ts.tscWatch { import projectsLocation = TestFSWithWatch.tsbuildProjectsLocation; import getFilePathInProject = TestFSWithWatch.getTsBuildProjectFilePath; import getFileFromProject = TestFSWithWatch.getTsBuildProjectFile; - type TsBuildWatchSystem = WatchedSystem & { writtenFiles: Map; }; + type TsBuildWatchSystem = TestFSWithWatch.TestServerHostTrackingWrittenFiles; function createTsBuildWatchSystem(fileOrFolderList: readonly TestFSWithWatch.FileOrFolderOrSymLink[], params?: TestFSWithWatch.TestServerHostCreationParameters) { - const host = createWatchedSystem(fileOrFolderList, params) as TsBuildWatchSystem; - const originalWriteFile = host.writeFile; - host.writtenFiles = createMap(); - host.writeFile = (fileName, content) => { - originalWriteFile.call(host, fileName, content); - const path = host.toFullPath(fileName); - host.writtenFiles.set(path, true); - }; - return host; + return TestFSWithWatch.changeToHostTrackingWrittenFiles( + createWatchedSystem(fileOrFolderList, params) + ); } export function createSolutionBuilder(system: WatchedSystem, rootNames: readonly string[], defaultOptions?: BuildOptions) { @@ -710,8 +704,8 @@ let x: string = 10;`); const coreIndexDts = projectFileName(SubProject.core, "index.d.ts"); const coreAnotherModuleDts = projectFileName(SubProject.core, "anotherModule.d.ts"); const logicIndexDts = projectFileName(SubProject.logic, "index.d.ts"); - const expectedWatchedFiles = () => [core[0], logic[0], ...tests, libFile].map(f => f.path).concat([coreIndexDts, coreAnotherModuleDts, logicIndexDts].map(f => f.toLowerCase())); const expectedWatchedDirectoriesRecursive = projectSystem.getTypeRootsFromLocation(projectPath(SubProject.tests)); + const expectedProjectFiles = () => [libFile, ...tests, ...logic.slice(1), ...core.slice(1, core.length - 1)].map(f => f.path); const expectedProgramFiles = () => [tests[1].path, libFile.path, coreIndexDts, coreAnotherModuleDts, logicIndexDts]; function createSolutionAndWatchMode() { @@ -723,12 +717,19 @@ let x: string = 10;`); } function verifyWatches(host: TsBuildWatchSystem, withTsserver?: boolean) { - verifyWatchesOfProject(host, withTsserver ? expectedWatchedFiles().filter(f => f !== tests[1].path.toLowerCase()) : expectedWatchedFiles(), expectedWatchedDirectoriesRecursive); + verifyWatchesOfProject( + host, + withTsserver ? + [...core.slice(0, core.length - 1), ...logic, tests[0], libFile].map(f => f.path.toLowerCase()) : + [core[0], logic[0], ...tests, libFile].map(f => f.path).concat([coreIndexDts, coreAnotherModuleDts, logicIndexDts].map(f => f.toLowerCase())), + expectedWatchedDirectoriesRecursive + ); } function verifyScenario( edit: (host: TsBuildWatchSystem, solutionBuilder: SolutionBuilder) => void, - expectedFilesAfterEdit: () => readonly string[] + expectedProgramFilesAfterEdit: () => readonly string[], + expectedProjectFilesAfterEdit: () => readonly string[] ) { it("with tsc-watch", () => { const { host, solutionBuilder, watch } = createSolutionAndWatchMode(); @@ -737,7 +738,7 @@ let x: string = 10;`); host.checkTimeoutQueueLengthAndRun(1); checkOutputErrorsIncremental(host, emptyArray); - checkProgramActualFiles(watch(), expectedFilesAfterEdit()); + checkProgramActualFiles(watch(), expectedProgramFilesAfterEdit()); }); @@ -747,7 +748,7 @@ let x: string = 10;`); edit(host, solutionBuilder); host.checkTimeoutQueueLengthAndRun(2); - checkProjectActualFiles(service, tests[0].path, [tests[0].path, ...expectedFilesAfterEdit()]); + checkProjectActualFiles(service, tests[0].path, expectedProjectFilesAfterEdit()); }); } @@ -777,7 +778,7 @@ function foo() { // not ideal, but currently because of d.ts but no new file is written // There will be timeout queued even though file contents are same - }, expectedProgramFiles); + }, expectedProgramFiles, expectedProjectFiles); }); describe("non local edit in ts file, rebuilds in watch compilation", () => { @@ -787,7 +788,7 @@ export function gfoo() { }`); solutionBuilder.invalidateProject(logic[0].path.toLowerCase() as ResolvedConfigFilePath); solutionBuilder.buildNextInvalidatedProject(); - }, expectedProgramFiles); + }, expectedProgramFiles, expectedProjectFiles); }); describe("change in project reference config file builds correctly", () => { @@ -798,7 +799,7 @@ export function gfoo() { })); solutionBuilder.invalidateProject(logic[0].path.toLowerCase() as ResolvedConfigFilePath, ConfigFileProgramReloadLevel.Full); solutionBuilder.buildNextInvalidatedProject(); - }, () => [tests[1].path, libFile.path, coreIndexDts, coreAnotherModuleDts, projectFilePath(SubProject.logic, "decls/index.d.ts")]); + }, () => [tests[1].path, libFile.path, coreIndexDts, coreAnotherModuleDts, projectFilePath(SubProject.logic, "decls/index.d.ts")], expectedProjectFiles); }); }); @@ -888,7 +889,9 @@ export function gfoo() { const aDts = dtsFile(multiFolder ? "a/index" : "a"), bDts = dtsFile(multiFolder ? "b/index" : "b"); const expectedFiles = [jsFile(multiFolder ? "a/index" : "a"), aDts, jsFile(multiFolder ? "b/index" : "b"), bDts, jsFile(multiFolder ? "c/index" : "c")]; const expectedProgramFiles = [cTs.path, libFile.path, aDts, refs.path, bDts]; + const expectedProjectFiles = [cTs.path, libFile.path, aTs.path, refs.path, bTs.path]; const expectedWatchedFiles = expectedProgramFiles.concat(cTsconfig.path, bTsconfig.path, aTsconfig.path).map(s => s.toLowerCase()); + const expectedProjectWatchedFiles = expectedProjectFiles.concat(cTsconfig.path, bTsconfig.path, aTsconfig.path).map(s => s.toLowerCase()); const expectedWatchedDirectories = multiFolder ? [ getProjectPath(project).toLowerCase() // watches for directories created for resolution of b ] : emptyArray; @@ -926,22 +929,29 @@ export function gfoo() { } function verifyProject(host: TsBuildWatchSystem, service: projectSystem.TestProjectService, orphanInfos?: readonly string[]) { - verifyServerState(host, service, expectedProgramFiles, expectedWatchedFiles, expectedWatchedDirectoriesRecursive, orphanInfos); + verifyServerState({ host, service, expectedProjectFiles, expectedProjectWatchedFiles, expectedWatchedDirectoriesRecursive, orphanInfos }); } - function verifyServerState( - host: TsBuildWatchSystem, - service: projectSystem.TestProjectService, - expectedProgramFiles: readonly string[], - expectedWatchedFiles: readonly string[], - expectedWatchedDirectoriesRecursive: readonly string[], - orphanInfos?: readonly string[]) { - checkProjectActualFiles(service, cTsconfig.path, expectedProgramFiles.concat(cTsconfig.path)); - const watchedFiles = expectedWatchedFiles.filter(f => f !== cTs.path.toLowerCase()); - if (orphanInfos) { + interface VerifyServerState { + host: TsBuildWatchSystem; + service: projectSystem.TestProjectService; + expectedProjectFiles: readonly string[]; + expectedProjectWatchedFiles: readonly string[]; + expectedWatchedDirectoriesRecursive: readonly string[]; + orphanInfos?: readonly string[]; + } + function verifyServerState({ host, service, expectedProjectFiles, expectedProjectWatchedFiles, expectedWatchedDirectoriesRecursive, orphanInfos }: VerifyServerState) { + checkProjectActualFiles(service, cTsconfig.path, expectedProjectFiles.concat(cTsconfig.path)); + const watchedFiles = expectedProjectWatchedFiles.filter(f => f !== cTs.path.toLowerCase()); + const actualOrphan = arrayFrom(mapDefinedIterator( + service.filenameToScriptInfo.values(), + v => v.containingProjects.length === 0 ? v.fileName : undefined + )); + assert.equal(actualOrphan.length, orphanInfos ? orphanInfos.length : 0, `Orphans found: ${JSON.stringify(actualOrphan, /*replacer*/ undefined, " ")}`); + if (orphanInfos && orphanInfos.length) { for (const orphan of orphanInfos) { const info = service.getScriptInfoForPath(orphan as Path); - assert.isDefined(info); + assert.isDefined(info, `${orphan} expected to be present. Actual: ${JSON.stringify(actualOrphan, /*replacer*/ undefined, " ")}`); assert.equal(info!.containingProjects.length, 0); watchedFiles.push(orphan); } @@ -949,16 +959,20 @@ export function gfoo() { verifyWatchesOfProject(host, watchedFiles, expectedWatchedDirectoriesRecursive, expectedWatchedDirectories); } - function verifyScenario( - edit: (host: TsBuildWatchSystem, solutionBuilder: SolutionBuilder) => void, - expectedEditErrors: readonly string[], - expectedProgramFiles: readonly string[], - expectedWatchedFiles: readonly string[], - expectedWatchedDirectoriesRecursive: readonly string[], - dependencies: readonly [string, readonly string[]][], - revert?: (host: TsBuildWatchSystem) => void, - orphanInfosAfterEdit?: readonly string[], - orphanInfosAfterRevert?: readonly string[]) { + interface VerifyScenario { + edit: (host: TsBuildWatchSystem, solutionBuilder: SolutionBuilder) => void; + expectedEditErrors: readonly string[]; + expectedProgramFiles: readonly string[]; + expectedProjectFiles: readonly string[]; + expectedWatchedFiles: readonly string[]; + expectedProjectWatchedFiles: readonly string[]; + expectedWatchedDirectoriesRecursive: readonly string[]; + dependencies: readonly [string, readonly string[]][]; + revert?: (host: TsBuildWatchSystem) => void; + orphanInfosAfterEdit?: readonly string[]; + orphanInfosAfterRevert?: readonly string[]; + } + function verifyScenario({ edit, expectedEditErrors, expectedProgramFiles, expectedProjectFiles, expectedWatchedFiles, expectedProjectWatchedFiles, expectedWatchedDirectoriesRecursive, dependencies, revert, orphanInfosAfterEdit, orphanInfosAfterRevert }: VerifyScenario) { it("with tsc-watch", () => { const { host, solutionBuilder, watch } = createSolutionAndWatchMode(); @@ -985,7 +999,7 @@ export function gfoo() { edit(host, solutionBuilder); host.checkTimeoutQueueLengthAndRun(2); - verifyServerState(host, service, expectedProgramFiles, expectedWatchedFiles, expectedWatchedDirectoriesRecursive, orphanInfosAfterEdit); + verifyServerState({ host, service, expectedProjectFiles, expectedProjectWatchedFiles, expectedWatchedDirectoriesRecursive, orphanInfos: orphanInfosAfterEdit }); if (revert) { revert(host); @@ -1010,20 +1024,21 @@ export function gfoo() { }); describe("non local edit updates the program and watch correctly", () => { - verifyScenario( - (host, solutionBuilder) => { + verifyScenario({ + edit: (host, solutionBuilder) => { // edit - host.writeFile(bTs.path, `${bTs.content} -export function gfoo() { -}`); - solutionBuilder.invalidateProject(bTsconfig.path.toLowerCase() as ResolvedConfigFilePath); + host.writeFile(bTs.path, `${bTs.content}\nexport function gfoo() {\n}`); + solutionBuilder.invalidateProject((bTsconfig.path.toLowerCase() as ResolvedConfigFilePath)); solutionBuilder.buildNextInvalidatedProject(); }, - emptyArray, + expectedEditErrors: emptyArray, expectedProgramFiles, + expectedProjectFiles, expectedWatchedFiles, + expectedProjectWatchedFiles, expectedWatchedDirectoriesRecursive, - defaultDependencies); + dependencies: defaultDependencies + }); }); describe("edit on config file", () => { @@ -1032,30 +1047,32 @@ export function gfoo() { path: getFilePathInProject(project, "nrefs/a.d.ts"), content: refs.content }; - verifyScenario( - host => { + verifyScenario({ + edit: host => { const cTsConfigJson = JSON.parse(cTsconfig.content); host.ensureFileOrFolder(nrefs); cTsConfigJson.compilerOptions.paths = { "@ref/*": nrefsPath }; host.writeFile(cTsconfig.path, JSON.stringify(cTsConfigJson)); }, - emptyArray, - expectedProgramFiles.map(nrefReplacer), - expectedWatchedFiles.map(nrefReplacer), - expectedWatchedDirectoriesRecursive.map(nrefReplacer), - [ + expectedEditErrors: emptyArray, + expectedProgramFiles: expectedProgramFiles.map(nrefReplacer), + expectedProjectFiles: expectedProjectFiles.map(nrefReplacer), + expectedWatchedFiles: expectedWatchedFiles.map(nrefReplacer), + expectedProjectWatchedFiles: expectedProjectWatchedFiles.map(nrefReplacer), + expectedWatchedDirectoriesRecursive: expectedWatchedDirectoriesRecursive.map(nrefReplacer), + dependencies: [ [aDts, [aDts]], [bDts, [bDts, aDts]], [nrefs.path, [nrefs.path]], [cTs.path, [cTs.path, nrefs.path, bDts]] ], // revert the update - host => host.writeFile(cTsconfig.path, cTsconfig.content), + revert: host => host.writeFile(cTsconfig.path, cTsconfig.content), // AfterEdit:: Extra watched files on server since the script infos arent deleted till next file open - [refs.path.toLowerCase()], + orphanInfosAfterEdit: [refs.path.toLowerCase()], // AfterRevert:: Extra watched files on server since the script infos arent deleted till next file open - [nrefs.path.toLowerCase()] - ); + orphanInfosAfterRevert: [nrefs.path.toLowerCase()] + }); }); describe("edit in referenced config file", () => { @@ -1064,82 +1081,84 @@ export function gfoo() { content: "export declare class A {}" }; const expectedProgramFiles = [cTs.path, bDts, nrefs.path, refs.path, libFile.path]; + const expectedProjectFiles = [cTs.path, bTs.path, nrefs.path, refs.path, libFile.path]; const [, ...expectedWatchedDirectoriesRecursiveWithoutA] = expectedWatchedDirectoriesRecursive; // Not looking in a folder for resolution in multi folder scenario - verifyScenario( - host => { + verifyScenario({ + edit: host => { const bTsConfigJson = JSON.parse(bTsconfig.content); host.ensureFileOrFolder(nrefs); bTsConfigJson.compilerOptions.paths = { "@ref/*": nrefsPath }; host.writeFile(bTsconfig.path, JSON.stringify(bTsConfigJson)); }, - emptyArray, + expectedEditErrors: emptyArray, expectedProgramFiles, - expectedProgramFiles.concat(cTsconfig.path, bTsconfig.path, aTsconfig.path).map(s => s.toLowerCase()), - (multiFolder ? expectedWatchedDirectoriesRecursiveWithoutA : expectedWatchedDirectoriesRecursive).concat(getFilePathInProject(project, "nrefs").toLowerCase()), - [ + expectedProjectFiles, + expectedWatchedFiles: expectedProgramFiles.concat(cTsconfig.path, bTsconfig.path, aTsconfig.path).map(s => s.toLowerCase()), + expectedProjectWatchedFiles: expectedProjectFiles.concat(cTsconfig.path, bTsconfig.path, aTsconfig.path).map(s => s.toLowerCase()), + expectedWatchedDirectoriesRecursive: (multiFolder ? expectedWatchedDirectoriesRecursiveWithoutA : expectedWatchedDirectoriesRecursive).concat(getFilePathInProject(project, "nrefs").toLowerCase()), + dependencies: [ [nrefs.path, [nrefs.path]], [bDts, [bDts, nrefs.path]], [refs.path, [refs.path]], [cTs.path, [cTs.path, refs.path, bDts]], ], // revert the update - host => host.writeFile(bTsconfig.path, bTsconfig.content), + revert: host => host.writeFile(bTsconfig.path, bTsconfig.content), // AfterEdit:: Extra watched files on server since the script infos arent deleted till next file open - [aDts.toLowerCase()], + orphanInfosAfterEdit: [aTs.path.toLowerCase()], // AfterRevert:: Extra watched files on server since the script infos arent deleted till next file open - [nrefs.path.toLowerCase()] - ); + orphanInfosAfterRevert: [nrefs.path.toLowerCase()] + }); }); describe("deleting referenced config file", () => { const expectedProgramFiles = [cTs.path, bTs.path, refs.path, libFile.path]; + const expectedWatchedFiles = expectedProgramFiles.concat(cTsconfig.path, bTsconfig.path).map(s => s.toLowerCase()); const [, ...expectedWatchedDirectoriesRecursiveWithoutA] = expectedWatchedDirectoriesRecursive; // Not looking in a folder for resolution in multi folder scenario // Resolutions should change now // Should map to b.ts instead with options from our own config - verifyScenario( - host => host.deleteFile(bTsconfig.path), - [ + verifyScenario({ + edit: host => host.deleteFile(bTsconfig.path), + expectedEditErrors: [ `${multiFolder ? "c/tsconfig.json" : "tsconfig.c.json"}(9,21): error TS6053: File '/user/username/projects/transitiveReferences/${multiFolder ? "b" : "tsconfig.b.json"}' not found.\n` ], expectedProgramFiles, - expectedProgramFiles.concat(cTsconfig.path, bTsconfig.path).map(s => s.toLowerCase()), - multiFolder ? expectedWatchedDirectoriesRecursiveWithoutA : expectedWatchedDirectoriesRecursive, - [ + expectedProjectFiles: expectedProgramFiles, + expectedWatchedFiles, + expectedProjectWatchedFiles: expectedWatchedFiles, + expectedWatchedDirectoriesRecursive: multiFolder ? expectedWatchedDirectoriesRecursiveWithoutA : expectedWatchedDirectoriesRecursive, + dependencies: [ [bTs.path, [bTs.path, refs.path]], [refs.path, [refs.path]], [cTs.path, [cTs.path, refs.path, bTs.path]], ], // revert the update - host => host.writeFile(bTsconfig.path, bTsconfig.content), + revert: host => host.writeFile(bTsconfig.path, bTsconfig.content), // AfterEdit:: Extra watched files on server since the script infos arent deleted till next file open - [bDts.toLowerCase(), aDts.toLowerCase(), aTsconfig.path.toLowerCase()], - // AfterRevert:: Extra watched files on server since the script infos arent deleted till next file open - [bTs.path.toLowerCase()] - ); + orphanInfosAfterEdit: [aTs.path.toLowerCase(), aTsconfig.path.toLowerCase()], + }); }); describe("deleting transitively referenced config file", () => { - verifyScenario( - host => host.deleteFile(aTsconfig.path), - [ + verifyScenario({ + edit: host => host.deleteFile(aTsconfig.path), + expectedEditErrors: [ `${multiFolder ? "b/tsconfig.json" : "tsconfig.b.json"}(10,21): error TS6053: File '/user/username/projects/transitiveReferences/${multiFolder ? "a" : "tsconfig.a.json"}' not found.\n` ], - expectedProgramFiles.map(s => s.replace(aDts, aTs.path)), - expectedWatchedFiles.map(s => s.replace(aDts.toLowerCase(), aTs.path.toLocaleLowerCase())), + expectedProgramFiles: expectedProgramFiles.map(s => s.replace(aDts, aTs.path)), + expectedProjectFiles, + expectedWatchedFiles: expectedWatchedFiles.map(s => s.replace(aDts.toLowerCase(), aTs.path.toLocaleLowerCase())), + expectedProjectWatchedFiles, expectedWatchedDirectoriesRecursive, - [ + dependencies: [ [aTs.path, [aTs.path]], [bDts, [bDts, aTs.path]], [refs.path, [refs.path]], [cTs.path, [cTs.path, refs.path, bDts]], ], // revert the update - host => host.writeFile(aTsconfig.path, aTsconfig.content), - // AfterEdit:: Extra watched files on server since the script infos arent deleted till next file open - [aDts.toLowerCase()], - // AfterRevert:: Extra watched files on server since the script infos arent deleted till next file open - [aTs.path.toLowerCase()] - ); + revert: host => host.writeFile(aTsconfig.path, aTsconfig.content), + }); }); } diff --git a/src/testRunner/unittests/tsc/declarationEmit.ts b/src/testRunner/unittests/tsc/declarationEmit.ts new file mode 100644 index 00000000000..5577ad22023 --- /dev/null +++ b/src/testRunner/unittests/tsc/declarationEmit.ts @@ -0,0 +1,136 @@ +namespace ts { + describe("unittests:: tsc:: declarationEmit::", () => { + verifyTsc({ + scenario: "declarationEmit", + subScenario: "when same version is referenced through source and another symlinked package", + fs: () => { + const fsaPackageJson = utils.dedent` + { + "name": "typescript-fsa", + "version": "3.0.0-beta-2" + }`; + const fsaIndex = utils.dedent` + export interface Action { + type: string; + payload: Payload; + } + export declare type ActionCreator = { + type: string; + (payload: Payload): Action; + } + export interface ActionCreatorFactory { + (type: string): ActionCreator; + } + export declare function actionCreatorFactory(prefix?: string | null): ActionCreatorFactory; + export default actionCreatorFactory;`; + return loadProjectFromFiles({ + "/src/plugin-two/index.d.ts": utils.dedent` + declare const _default: { + features: { + featureOne: { + actions: { + featureOne: { + (payload: { + name: string; + order: number; + }, meta?: { + [key: string]: any; + }): import("typescript-fsa").Action<{ + name: string; + order: number; + }>; + }; + }; + path: string; + }; + }; + }; + export default _default;`, + "/src/plugin-two/node_modules/typescript-fsa/package.json": fsaPackageJson, + "/src/plugin-two/node_modules/typescript-fsa/index.d.ts": fsaIndex, + "/src/plugin-one/tsconfig.json": utils.dedent` + { + "compilerOptions": { + "target": "es5", + "declaration": true, + }, + }`, + "/src/plugin-one/index.ts": utils.dedent` + import pluginTwo from "plugin-two"; // include this to add reference to symlink`, + "/src/plugin-one/action.ts": utils.dedent` + import { actionCreatorFactory } from "typescript-fsa"; // Include version of shared lib + const action = actionCreatorFactory("somekey"); + const featureOne = action<{ route: string }>("feature-one"); + export const actions = { featureOne };`, + "/src/plugin-one/node_modules/typescript-fsa/package.json": fsaPackageJson, + "/src/plugin-one/node_modules/typescript-fsa/index.d.ts": fsaIndex, + "/src/plugin-one/node_modules/plugin-two": new vfs.Symlink("/src/plugin-two"), + }); + }, + commandLineArgs: ["-p", "src/plugin-one", "--listFiles"] + }); + + verifyTsc({ + scenario: "declarationEmit", + subScenario: "when pkg references sibling package through indirect symlink", + fs: () => loadProjectFromFiles({ + "/src/pkg1/dist/index.d.ts": utils.dedent` + export * from './types';`, + "/src/pkg1/dist/types.d.ts": utils.dedent` + export declare type A = { + id: string; + }; + export declare type B = { + id: number; + }; + export declare type IdType = A | B; + export declare class MetadataAccessor { + readonly key: string; + private constructor(); + toString(): string; + static create(key: string): MetadataAccessor; + }`, + "/src/pkg1/package.json": utils.dedent` + { + "name": "@raymondfeng/pkg1", + "version": "1.0.0", + "description": "", + "main": "dist/index.js", + "typings": "dist/index.d.ts" + }`, + "/src/pkg2/dist/index.d.ts": utils.dedent` + export * from './types';`, + "/src/pkg2/dist/types.d.ts": utils.dedent` + export {MetadataAccessor} from '@raymondfeng/pkg1';`, + "/src/pkg2/package.json": utils.dedent` + { + "name": "@raymondfeng/pkg2", + "version": "1.0.0", + "description": "", + "main": "dist/index.js", + "typings": "dist/index.d.ts" + }`, + "/src/pkg3/src/index.ts": utils.dedent` + export * from './keys';`, + "/src/pkg3/src/keys.ts": utils.dedent` + import {MetadataAccessor} from "@raymondfeng/pkg2"; + export const ADMIN = MetadataAccessor.create('1');`, + "/src/pkg3/tsconfig.json": utils.dedent` + { + "compilerOptions": { + "outDir": "dist", + "rootDir": "src", + "target": "es5", + "module": "commonjs", + "strict": true, + "esModuleInterop": true, + "declaration": true + } + }`, + "/src/pkg2/node_modules/@raymondfeng/pkg1": new vfs.Symlink("/src/pkg1"), + "/src/pkg3/node_modules/@raymondfeng/pkg2": new vfs.Symlink("/src/pkg2"), + }), + commandLineArgs: ["-p", "src/pkg3", "--listFiles"] + }); + }); +} diff --git a/src/testRunner/unittests/tsc/helpers.ts b/src/testRunner/unittests/tsc/helpers.ts new file mode 100644 index 00000000000..ad1d64ac285 --- /dev/null +++ b/src/testRunner/unittests/tsc/helpers.ts @@ -0,0 +1,243 @@ +namespace ts { + export type TscCompileSystem = fakes.System & { + writtenFiles: Map; + baseLine(): void; + }; + function executeCommandLine(sys: TscCompileSystem, commandLineArgs: readonly string[]) { + if (isBuild(commandLineArgs)) { + return performBuild(sys, commandLineArgs.slice(1)); + } + + const reportDiagnostic = createDiagnosticReporter(sys); + const commandLine = parseCommandLine(commandLineArgs, path => sys.readFile(path)); + if (commandLine.options.build) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_build_must_be_the_first_command_line_argument)); + return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); + } + + if (commandLine.errors.length > 0) { + commandLine.errors.forEach(reportDiagnostic); + return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); + } + + let configFileName: string | undefined; + if (commandLine.options.project) { + if (commandLine.fileNames.length !== 0) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line)); + return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); + } + + const fileOrDirectory = normalizePath(commandLine.options.project); + if (!fileOrDirectory /* current directory "." */ || sys.directoryExists(fileOrDirectory)) { + configFileName = combinePaths(fileOrDirectory, "tsconfig.json"); + if (!sys.fileExists(configFileName)) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0, commandLine.options.project)); + return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); + } + } + else { + configFileName = fileOrDirectory; + if (!sys.fileExists(configFileName)) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_specified_path_does_not_exist_Colon_0, commandLine.options.project)); + return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); + } + } + } + else if (commandLine.fileNames.length === 0) { + const searchPath = normalizePath(sys.getCurrentDirectory()); + configFileName = findConfigFile(searchPath, sys.fileExists); + } + + Debug.assert(commandLine.fileNames.length !== 0 || !!configFileName); + + if (configFileName) { + const configParseResult = Debug.assertDefined(parseConfigFileWithSystem(configFileName, commandLine.options, sys, reportDiagnostic)); + if (isIncrementalCompilation(configParseResult.options)) { + performIncrementalCompilation(sys, configParseResult); + } + else { + performCompilation(sys, configParseResult); + } + } + else { + if (isIncrementalCompilation(commandLine.options)) { + performIncrementalCompilation(sys, commandLine); + } + else { + performCompilation(sys, commandLine); + } + } + } + + function createReportErrorSummary(sys: TscCompileSystem, options: CompilerOptions): ReportEmitErrorSummary | undefined { + return options.pretty ? + errorCount => sys.write(getErrorSummaryText(errorCount, sys.newLine)) : + undefined; + } + + function performCompilation(sys: TscCompileSystem, config: ParsedCommandLine) { + const { fileNames, options, projectReferences } = config; + const reportDiagnostic = createDiagnosticReporter(sys, options.pretty); + const host = createCompilerHostWorker(options, /*setParentPos*/ undefined, sys); + const currentDirectory = host.getCurrentDirectory(); + const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames()); + changeCompilerHostLikeToUseCache(host, fileName => toPath(fileName, currentDirectory, getCanonicalFileName)); + const program = createProgram({ + rootNames: fileNames, + options, + projectReferences, + host, + configFileParsingDiagnostics: getConfigFileParsingDiagnostics(config) + }); + const exitStatus = emitFilesAndReportErrorsAndGetExitStatus( + program, + reportDiagnostic, + s => sys.write(s + sys.newLine), + createReportErrorSummary(sys, options) + ); + baselineBuildInfo([config], sys.vfs, sys.writtenFiles); + return sys.exit(exitStatus); + } + + function performIncrementalCompilation(sys: TscCompileSystem, config: ParsedCommandLine) { + const reportDiagnostic = createDiagnosticReporter(sys, config.options.pretty); + const { options, fileNames, projectReferences } = config; + const exitCode = ts.performIncrementalCompilation({ + system: sys, + rootNames: fileNames, + options, + configFileParsingDiagnostics: getConfigFileParsingDiagnostics(config), + projectReferences, + reportDiagnostic, + reportErrorSummary: createReportErrorSummary(sys, options), + }); + baselineBuildInfo([config], sys.vfs, sys.writtenFiles); + return sys.exit(exitCode); + } + + function performBuild(sys: TscCompileSystem, args: string[]) { + const { buildOptions, projects, errors } = parseBuildCommand(args); + const reportDiagnostic = createDiagnosticReporter(sys, buildOptions.pretty); + + if (errors.length > 0) { + errors.forEach(reportDiagnostic); + return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); + } + + Debug.assert(projects.length !== 0); + + const buildHost = createSolutionBuilderHost( + sys, + /*createProgram*/ undefined, + reportDiagnostic, + createBuilderStatusReporter(sys, buildOptions.pretty), + createReportErrorSummary(sys, buildOptions) + ); + fakes.patchSolutionBuilderHost(buildHost, sys); + const builder = createSolutionBuilder(buildHost, projects, buildOptions); + const exitCode = buildOptions.clean ? builder.clean() : builder.build(); + baselineBuildInfo(builder.getAllParsedConfigs(), sys.vfs, sys.writtenFiles); + return sys.exit(exitCode); + } + + function isBuild(commandLineArgs: readonly string[]) { + if (commandLineArgs.length > 0 && commandLineArgs[0].charCodeAt(0) === CharacterCodes.minus) { + const firstOption = commandLineArgs[0].slice(commandLineArgs[0].charCodeAt(1) === CharacterCodes.minus ? 2 : 1).toLowerCase(); + return firstOption === "build" || firstOption === "b"; + } + return false; + } + + export enum BuildKind { + Initial = "initial-build", + IncrementalDtsChange = "incremental-declaration-changes", + IncrementalDtsUnchanged = "incremental-declaration-doesnt-change", + IncrementalHeadersChange = "incremental-headers-change-without-dts-changes" + } + + export interface TscCompile { + scenario: string; + subScenario: string; + buildKind?: BuildKind; // Should be defined for tsc --b + fs: () => vfs.FileSystem; + commandLineArgs: readonly string[]; + + modifyFs?: (fs: vfs.FileSystem) => void; + baselineSourceMap?: boolean; + baselineReadFileCalls?: boolean; + } + + export function tscCompile(input: TscCompile) { + const baseFs = input.fs(); + const fs = baseFs.shadow(); + const { + scenario, subScenario, buildKind, + commandLineArgs, modifyFs, + baselineSourceMap, baselineReadFileCalls + } = input; + if (modifyFs) modifyFs(fs); + + // Create system + const sys = new fakes.System(fs, { executingFilePath: "/lib/tsc" }) as TscCompileSystem; + const writtenFiles = sys.writtenFiles = createMap(); + const originalWriteFile = sys.writeFile; + sys.writeFile = (fileName, content, writeByteOrderMark) => { + assert.isFalse(writtenFiles.has(fileName)); + writtenFiles.set(fileName, true); + return originalWriteFile.call(sys, fileName, content, writeByteOrderMark); + }; + const actualReadFileMap: MapLike = {}; + const originalReadFile = sys.readFile; + sys.readFile = path => { + // Dont record libs + if (path.startsWith("/src/")) { + actualReadFileMap[path] = (getProperty(actualReadFileMap, path) || 0) + 1; + } + return originalReadFile.call(sys, path); + }; + + sys.write(`${sys.getExecutingFilePath()} ${commandLineArgs.join(" ")}\n`); + sys.exit = exitCode => sys.exitCode = exitCode; + executeCommandLine(sys, commandLineArgs); + sys.write(`exitCode:: ${sys.exitCode}\n`); + if (baselineReadFileCalls) { + sys.write(`readFiles:: ${JSON.stringify(actualReadFileMap, /*replacer*/ undefined, " ")} `); + } + if (baselineSourceMap) generateSourceMapBaselineFiles(fs, mapDefinedIterator(writtenFiles.keys(), f => f.endsWith(".map") ? f : undefined)); + + // Baseline the errors + fs.writeFileSync(`/lib/${buildKind || BuildKind.Initial}Output.txt`, sys.output.join("")); + fs.makeReadonly(); + + sys.baseLine = () => { + const patch = fs.diff(baseFs, { includeChangedFileWithSameContent: true }); + // eslint-disable-next-line no-null/no-null + Harness.Baseline.runBaseline(`${isBuild(commandLineArgs) ? "tsbuild" : "tsc"}/${scenario}/${buildKind || BuildKind.Initial}/${subScenario.split(" ").join("-")}.js`, patch ? vfs.formatPatch(patch) : null); + }; + return sys; + } + + export function verifyTscBaseline(sys: () => TscCompileSystem) { + it(`Generates files matching the baseline`, () => { + sys().baseLine(); + }); + } + + export function verifyTsc(input: TscCompile) { + describe(input.scenario, () => { + describe(input.subScenario, () => { + let sys: TscCompileSystem; + before(() => { + sys = tscCompile({ + ...input, + fs: () => getFsWithTime(input.fs()).fs.makeReadonly() + }); + }); + after(() => { + sys = undefined!; + }); + verifyTscBaseline(() => sys); + }); + }); + } +} diff --git a/src/testRunner/unittests/tsserver/declarationFileMaps.ts b/src/testRunner/unittests/tsserver/declarationFileMaps.ts index d1c64fe46ce..a6f217385d9 100644 --- a/src/testRunner/unittests/tsserver/declarationFileMaps.ts +++ b/src/testRunner/unittests/tsserver/declarationFileMaps.ts @@ -179,7 +179,7 @@ namespace ts.projectSystem { } function verifyUserTsConfigProject(session: TestSession) { - checkProjectActualFiles(session.getProjectService().configuredProjects.get(userTsconfig.path)!, [userTs.path, aDts.path, userTsconfig.path]); + checkProjectActualFiles(session.getProjectService().configuredProjects.get(userTsconfig.path)!, [userTs.path, aTs.path, userTsconfig.path]); } it("goToDefinition", () => { @@ -450,6 +450,13 @@ namespace ts.projectSystem { name: "function f(): void", }, references: [ + makeReferenceEntry({ + file: aTs, + text: "f", + options: { index: 1 }, + contextText: "function f() {}", + isDefinition: true + }), { fileName: bTs.path, isDefinition: false, @@ -457,13 +464,6 @@ namespace ts.projectSystem { isWriteAccess: false, textSpan: { start: 0, length: 1 }, }, - makeReferenceEntry({ - file: aTs, - text: "f", - options: { index: 1 }, - contextText: "function f() {}", - isDefinition: true - }) ], } ]); diff --git a/src/testRunner/unittests/tsserver/events/projectLoading.ts b/src/testRunner/unittests/tsserver/events/projectLoading.ts index cb22f41ff25..5f4bf1a52c9 100644 --- a/src/testRunner/unittests/tsserver/events/projectLoading.ts +++ b/src/testRunner/unittests/tsserver/events/projectLoading.ts @@ -73,44 +73,64 @@ namespace ts.projectSystem { verifyEvent(project, `Change in config file detected`); }); - it("when opening original location project", () => { - const aDTs: File = { - path: `${projectRoot}/a/a.d.ts`, - content: `export declare class A { + describe("when opening original location project", () => { + it("with project references", () => { + verify(); + }); + + it("when disableSourceOfProjectReferenceRedirect is true", () => { + verify(/*disableSourceOfProjectReferenceRedirect*/ true); + }); + + function verify(disableSourceOfProjectReferenceRedirect?: true) { + const aDTs: File = { + path: `${projectRoot}/a/a.d.ts`, + content: `export declare class A { } //# sourceMappingURL=a.d.ts.map ` - }; - const aDTsMap: File = { - path: `${projectRoot}/a/a.d.ts.map`, - content: `{"version":3,"file":"a.d.ts","sourceRoot":"","sources":["./a.ts"],"names":[],"mappings":"AAAA,qBAAa,CAAC;CAAI"}` - }; - const bTs: File = { - path: bTsPath, - content: `import {A} from "../a/a"; new A();` - }; - const configB: File = { - path: configBPath, - content: JSON.stringify({ - references: [{ path: "../a" }] - }) - }; + }; + const aDTsMap: File = { + path: `${projectRoot}/a/a.d.ts.map`, + content: `{"version":3,"file":"a.d.ts","sourceRoot":"","sources":["./a.ts"],"names":[],"mappings":"AAAA,qBAAa,CAAC;CAAI"}` + }; + const bTs: File = { + path: bTsPath, + content: `import {A} from "../a/a"; new A();` + }; + const configB: File = { + path: configBPath, + content: JSON.stringify({ + ...(disableSourceOfProjectReferenceRedirect && { + compilerOptions: { + disableSourceOfProjectReferenceRedirect + } + }), + references: [{ path: "../a" }] + }) + }; - const { service, session, verifyEventWithOpenTs, verifyEvent } = createSessionToVerifyEvent(files.concat(aDTs, aDTsMap, bTs, configB)); - verifyEventWithOpenTs(bTs, configB.path, 1); + const { service, session, verifyEventWithOpenTs, verifyEvent } = createSessionToVerifyEvent(files.concat(aDTs, aDTsMap, bTs, configB)); + verifyEventWithOpenTs(bTs, configB.path, 1); - session.executeCommandSeq({ - command: protocol.CommandTypes.References, - arguments: { - file: bTs.path, - ...protocolLocationFromSubstring(bTs.content, "A()") - } - }); + session.executeCommandSeq({ + command: protocol.CommandTypes.References, + arguments: { + file: bTs.path, + ...protocolLocationFromSubstring(bTs.content, "A()") + } + }); - checkNumberOfProjects(service, { configuredProjects: 2 }); - const project = service.configuredProjects.get(configA.path)!; - assert.isDefined(project); - verifyEvent(project, `Creating project for original file: ${aTs.path} for location: ${aDTs.path}`); + checkNumberOfProjects(service, { configuredProjects: 2 }); + const project = service.configuredProjects.get(configA.path)!; + assert.isDefined(project); + verifyEvent( + project, + disableSourceOfProjectReferenceRedirect ? + `Creating project for original file: ${aTs.path} for location: ${aDTs.path}` : + `Creating project for original file: ${aTs.path}` + ); + } }); describe("with external projects and config files ", () => { diff --git a/src/testRunner/unittests/tsserver/helpers.ts b/src/testRunner/unittests/tsserver/helpers.ts index 1fb35935906..a8c79d0b603 100644 --- a/src/testRunner/unittests/tsserver/helpers.ts +++ b/src/testRunner/unittests/tsserver/helpers.ts @@ -491,8 +491,8 @@ namespace ts.projectSystem { checkArray("Open files", arrayFrom(projectService.openFiles.keys(), path => projectService.getScriptInfoForPath(path as Path)!.fileName), expectedFiles.map(file => file.path)); } - export function checkScriptInfos(projectService: server.ProjectService, expectedFiles: readonly string[]) { - checkArray("ScriptInfos files", arrayFrom(projectService.filenameToScriptInfo.values(), info => info.fileName), expectedFiles); + export function checkScriptInfos(projectService: server.ProjectService, expectedFiles: readonly string[], additionInfo?: string) { + checkArray(`ScriptInfos files: ${additionInfo || ""}`, arrayFrom(projectService.filenameToScriptInfo.values(), info => info.fileName), expectedFiles); } export function protocolLocationFromSubstring(str: string, substring: string): protocol.Location { @@ -501,7 +501,7 @@ namespace ts.projectSystem { return protocolToLocation(str)(start); } - function protocolToLocation(text: string): (pos: number) => protocol.Location { + export function protocolToLocation(text: string): (pos: number) => protocol.Location { const lineStarts = computeLineStarts(text); return pos => { const x = computeLineAndCharacterOfPosition(lineStarts, pos); diff --git a/src/testRunner/unittests/tsserver/projectReferenceCompileOnSave.ts b/src/testRunner/unittests/tsserver/projectReferenceCompileOnSave.ts new file mode 100644 index 00000000000..9602ef6360e --- /dev/null +++ b/src/testRunner/unittests/tsserver/projectReferenceCompileOnSave.ts @@ -0,0 +1,410 @@ +namespace ts.projectSystem { + describe("unittests:: tsserver:: with project references and compile on save", () => { + const projectLocation = "/user/username/projects/myproject"; + const dependecyLocation = `${projectLocation}/dependency`; + const usageLocation = `${projectLocation}/usage`; + const dependencyTs: File = { + path: `${dependecyLocation}/fns.ts`, + content: `export function fn1() { } +export function fn2() { } +` + }; + const dependencyConfig: File = { + path: `${dependecyLocation}/tsconfig.json`, + content: JSON.stringify({ + compilerOptions: { composite: true, declarationDir: "../decls" }, + compileOnSave: true + }) + }; + const usageTs: File = { + path: `${usageLocation}/usage.ts`, + content: `import { + fn1, + fn2, +} from '../decls/fns' +fn1(); +fn2(); +` + }; + const usageConfig: File = { + path: `${usageLocation}/tsconfig.json`, + content: JSON.stringify({ + compileOnSave: true, + references: [{ path: "../dependency" }] + }) + }; + + interface VerifySingleScenarioWorker extends VerifySingleScenario { + withProject: boolean; + } + function verifySingleScenarioWorker({ + withProject, scenario, openFiles, requestArgs, change, expectedResult + }: VerifySingleScenarioWorker) { + it(scenario, () => { + const host = TestFSWithWatch.changeToHostTrackingWrittenFiles( + createServerHost([dependencyTs, dependencyConfig, usageTs, usageConfig, libFile]) + ); + const session = createSession(host); + openFilesForSession(openFiles(), session); + const reqArgs = requestArgs(); + const { + expectedAffected, + expectedEmit: { expectedEmitSuccess, expectedFiles }, + expectedEmitOutput + } = expectedResult(withProject); + + if (change) { + session.executeCommandSeq({ + command: protocol.CommandTypes.CompileOnSaveAffectedFileList, + arguments: { file: dependencyTs.path } + }); + const { file, insertString } = change(); + if (session.getProjectService().openFiles.has(file.path)) { + const toLocation = protocolToLocation(file.content); + const location = toLocation(file.content.length); + session.executeCommandSeq({ + command: protocol.CommandTypes.Change, + arguments: { + file: file.path, + ...location, + endLine: location.line, + endOffset: location.offset, + insertString + } + }); + } + else { + host.writeFile(file.path, `${file.content}${insertString}`); + } + host.writtenFiles.clear(); + } + + const args = withProject ? reqArgs : { file: reqArgs.file }; + // Verify CompileOnSaveAffectedFileList + const actualAffectedFiles = session.executeCommandSeq({ + command: protocol.CommandTypes.CompileOnSaveAffectedFileList, + arguments: args + }).response as protocol.CompileOnSaveAffectedFileListSingleProject[]; + assert.deepEqual(actualAffectedFiles, expectedAffected, "Affected files"); + + // Verify CompileOnSaveEmit + const actualEmit = session.executeCommandSeq({ + command: protocol.CommandTypes.CompileOnSaveEmitFile, + arguments: args + }).response; + assert.deepEqual(actualEmit, expectedEmitSuccess, "Emit files"); + assert.equal(host.writtenFiles.size, expectedFiles.length); + for (const file of expectedFiles) { + assert.equal(host.readFile(file.path), file.content, `Expected to write ${file.path}`); + assert.isTrue(host.writtenFiles.has(file.path), `${file.path} is newly written`); + } + + // Verify EmitOutput + const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq({ + command: protocol.CommandTypes.EmitOutput, + arguments: args + }).response as EmitOutput; + assert.deepEqual(actualEmitOutput, expectedEmitOutput, "Emit output"); + }); + } + + interface VerifySingleScenario { + scenario: string; + openFiles: () => readonly File[]; + requestArgs: () => protocol.FileRequestArgs; + skipWithoutProject?: boolean; + change?: () => SingleScenarioChange; + expectedResult: GetSingleScenarioResult; + } + function verifySingleScenario(scenario: VerifySingleScenario) { + if (!scenario.skipWithoutProject) { + describe("without specifying project file", () => { + verifySingleScenarioWorker({ + withProject: false, + ...scenario + }); + }); + } + describe("with specifying project file", () => { + verifySingleScenarioWorker({ + withProject: true, + ...scenario + }); + }); + } + + interface SingleScenarioExpectedEmit { + expectedEmitSuccess: boolean; + expectedFiles: readonly File[]; + } + interface SingleScenarioResult { + expectedAffected: protocol.CompileOnSaveAffectedFileListSingleProject[]; + expectedEmit: SingleScenarioExpectedEmit; + expectedEmitOutput: EmitOutput; + } + type GetSingleScenarioResult = (withProject: boolean) => SingleScenarioResult; + interface SingleScenarioChange { + file: File; + insertString: string; + } + interface ScenarioDetails { + scenarioName: string; + requestArgs: () => protocol.FileRequestArgs; + skipWithoutProject?: boolean; + initial: GetSingleScenarioResult; + localChangeToDependency: GetSingleScenarioResult; + localChangeToUsage: GetSingleScenarioResult; + changeToDependency: GetSingleScenarioResult; + changeToUsage: GetSingleScenarioResult; + } + interface VerifyScenario { + openFiles: () => readonly File[]; + scenarios: readonly ScenarioDetails[]; + } + + const localChange = "function fn3() { }"; + const change = `export ${localChange}`; + const changeJs = `function fn3() { } +exports.fn3 = fn3;`; + const changeDts = "export declare function fn3(): void;"; + function verifyScenario({ openFiles, scenarios }: VerifyScenario) { + for (const { + scenarioName, requestArgs, skipWithoutProject, initial, + localChangeToDependency, localChangeToUsage, + changeToDependency, changeToUsage + } of scenarios) { + describe(scenarioName, () => { + verifySingleScenario({ + scenario: "with initial file open", + openFiles, + requestArgs, + skipWithoutProject, + expectedResult: initial + }); + + verifySingleScenario({ + scenario: "with local change to dependency", + openFiles, + requestArgs, + skipWithoutProject, + change: () => ({ file: dependencyTs, insertString: localChange }), + expectedResult: localChangeToDependency + }); + + verifySingleScenario({ + scenario: "with local change to usage", + openFiles, + requestArgs, + skipWithoutProject, + change: () => ({ file: usageTs, insertString: localChange }), + expectedResult: localChangeToUsage + }); + + verifySingleScenario({ + scenario: "with change to dependency", + openFiles, + requestArgs, + skipWithoutProject, + change: () => ({ file: dependencyTs, insertString: change }), + expectedResult: changeToDependency + }); + + verifySingleScenario({ + scenario: "with change to usage", + openFiles, + requestArgs, + skipWithoutProject, + change: () => ({ file: usageTs, insertString: change }), + expectedResult: changeToUsage + }); + }); + } + } + + function expectedAffectedFiles(config: File, fileNames: File[]): protocol.CompileOnSaveAffectedFileListSingleProject { + return { + projectFileName: config.path, + fileNames: fileNames.map(f => f.path), + projectUsesOutFile: false + }; + } + + function expectedUsageEmit(appendJsText?: string): SingleScenarioExpectedEmit { + const appendJs = appendJsText ? `${appendJsText} +` : ""; + return { + expectedEmitSuccess: true, + expectedFiles: [{ + path: `${usageLocation}/usage.js`, + content: `"use strict"; +exports.__esModule = true; +var fns_1 = require("../decls/fns"); +fns_1.fn1(); +fns_1.fn2(); +${appendJs}` + }] + }; + } + + function expectedEmitOutput({ expectedFiles }: SingleScenarioExpectedEmit): EmitOutput { + return { + outputFiles: expectedFiles.map(({ path, content }) => ({ + name: path, + text: content, + writeByteOrderMark: false + })), + emitSkipped: false + }; + } + + function expectedUsageEmitOutput(appendJsText?: string): EmitOutput { + return expectedEmitOutput(expectedUsageEmit(appendJsText)); + } + + function noEmit(): SingleScenarioExpectedEmit { + return { + expectedEmitSuccess: false, + expectedFiles: emptyArray + }; + } + + function noEmitOutput(): EmitOutput { + return { + emitSkipped: true, + outputFiles: [] + }; + } + + function expectedDependencyEmit(appendJsText?: string, appendDtsText?: string): SingleScenarioExpectedEmit { + const appendJs = appendJsText ? `${appendJsText} +` : ""; + const appendDts = appendDtsText ? `${appendDtsText} +` : ""; + return { + expectedEmitSuccess: true, + expectedFiles: [ + { + path: `${dependecyLocation}/fns.js`, + content: `"use strict"; +exports.__esModule = true; +function fn1() { } +exports.fn1 = fn1; +function fn2() { } +exports.fn2 = fn2; +${appendJs}` + }, + { + path: `${projectLocation}/decls/fns.d.ts`, + content: `export declare function fn1(): void; +export declare function fn2(): void; +${appendDts}` + } + ] + }; + } + + function expectedDependencyEmitOutput(appendJsText?: string, appendDtsText?: string): EmitOutput { + return expectedEmitOutput(expectedDependencyEmit(appendJsText, appendDtsText)); + } + + function scenarioDetailsOfUsage(isDependencyOpen?: boolean): ScenarioDetails[] { + return [ + { + scenarioName: "Of usageTs", + requestArgs: () => ({ file: usageTs.path, projectFileName: usageConfig.path }), + initial: () => initialUsageTs(), + // no change to usage so same as initial only usage file + localChangeToDependency: () => initialUsageTs(), + localChangeToUsage: () => initialUsageTs(localChange), + changeToDependency: () => initialUsageTs(), + changeToUsage: () => initialUsageTs(changeJs) + }, + { + scenarioName: "Of dependencyTs in usage project", + requestArgs: () => ({ file: dependencyTs.path, projectFileName: usageConfig.path }), + skipWithoutProject: !!isDependencyOpen, + initial: () => initialDependencyTs(), + localChangeToDependency: () => initialDependencyTs(/*noUsageFiles*/ true), + localChangeToUsage: () => initialDependencyTs(/*noUsageFiles*/ true), + changeToDependency: () => initialDependencyTs(), + changeToUsage: () => initialDependencyTs(/*noUsageFiles*/ true) + } + ]; + + function initialUsageTs(jsText?: string) { + return { + expectedAffected: [ + expectedAffectedFiles(usageConfig, [usageTs]) + ], + expectedEmit: expectedUsageEmit(jsText), + expectedEmitOutput: expectedUsageEmitOutput(jsText) + }; + } + + function initialDependencyTs(noUsageFiles?: true) { + return { + expectedAffected: [ + expectedAffectedFiles(usageConfig, noUsageFiles ? [] : [usageTs]) + ], + expectedEmit: noEmit(), + expectedEmitOutput: noEmitOutput() + }; + } + } + + function scenarioDetailsOfDependencyWhenOpen(): ScenarioDetails { + return { + scenarioName: "Of dependencyTs", + requestArgs: () => ({ file: dependencyTs.path, projectFileName: dependencyConfig.path }), + initial, + localChangeToDependency: withProject => ({ + expectedAffected: withProject ? + [ + expectedAffectedFiles(dependencyConfig, [dependencyTs]) + ] : + [ + expectedAffectedFiles(usageConfig, []), + expectedAffectedFiles(dependencyConfig, [dependencyTs]) + ], + expectedEmit: expectedDependencyEmit(localChange), + expectedEmitOutput: expectedDependencyEmitOutput(localChange) + }), + localChangeToUsage: withProject => initial(withProject, /*noUsageFiles*/ true), + changeToDependency: withProject => initial(withProject, /*noUsageFiles*/ undefined, changeJs, changeDts), + changeToUsage: withProject => initial(withProject, /*noUsageFiles*/ true) + }; + + function initial(withProject: boolean, noUsageFiles?: true, appendJs?: string, appendDts?: string): SingleScenarioResult { + return { + expectedAffected: withProject ? + [ + expectedAffectedFiles(dependencyConfig, [dependencyTs]) + ] : + [ + expectedAffectedFiles(usageConfig, noUsageFiles ? [] : [usageTs]), + expectedAffectedFiles(dependencyConfig, [dependencyTs]) + ], + expectedEmit: expectedDependencyEmit(appendJs, appendDts), + expectedEmitOutput: expectedDependencyEmitOutput(appendJs, appendDts) + }; + } + } + + describe("when dependency project is not open", () => { + verifyScenario({ + openFiles: () => [usageTs], + scenarios: scenarioDetailsOfUsage() + }); + }); + + describe("when the depedency file is open", () => { + verifyScenario({ + openFiles: () => [usageTs, dependencyTs], + scenarios: [ + ...scenarioDetailsOfUsage(/*isDependencyOpen*/ true), + scenarioDetailsOfDependencyWhenOpen(), + ] + }); + }); + }); +} diff --git a/src/testRunner/unittests/tsserver/projectReferenceErrors.ts b/src/testRunner/unittests/tsserver/projectReferenceErrors.ts new file mode 100644 index 00000000000..a3ec4848615 --- /dev/null +++ b/src/testRunner/unittests/tsserver/projectReferenceErrors.ts @@ -0,0 +1,430 @@ +namespace ts.projectSystem { + describe("unittests:: tsserver:: with project references and error reporting", () => { + const projectLocation = "/user/username/projects/myproject"; + const dependecyLocation = `${projectLocation}/dependency`; + const usageLocation = `${projectLocation}/usage`; + + interface CheckErrorsInFile { + session: TestSession; + host: TestServerHost; + expected: GetErrDiagnostics; + expectedSequenceId?: number; + } + function checkErrorsInFile({ session, host, expected: { file, syntax, semantic, suggestion }, expectedSequenceId }: CheckErrorsInFile) { + host.checkTimeoutQueueLengthAndRun(1); + checkErrorMessage(session, "syntaxDiag", { file: file.path, diagnostics: syntax }); + session.clearMessages(); + + host.runQueuedImmediateCallbacks(1); + checkErrorMessage(session, "semanticDiag", { file: file.path, diagnostics: semantic }); + session.clearMessages(); + + host.runQueuedImmediateCallbacks(1); + checkErrorMessage(session, "suggestionDiag", { file: file.path, diagnostics: suggestion }); + if (expectedSequenceId !== undefined) { + checkCompleteEvent(session, 2, expectedSequenceId); + } + session.clearMessages(); + } + + interface CheckAllErrors { + session: TestSession; + host: TestServerHost; + expected: readonly GetErrDiagnostics[]; + expectedSequenceId: number; + } + function checkAllErrors({ session, host, expected, expectedSequenceId }: CheckAllErrors) { + for (let i = 0; i < expected.length; i++) { + checkErrorsInFile({ + session, + host, + expected: expected[i], + expectedSequenceId: i === expected.length - 1 ? expectedSequenceId : undefined + }); + } + } + + function verifyErrorsUsingGeterr({ allFiles, openFiles, expectedGetErr }: VerifyScenario) { + it("verifies the errors in open file", () => { + const host = createServerHost([...allFiles(), libFile]); + const session = createSession(host, { canUseEvents: true, }); + openFilesForSession(openFiles(), session); + + session.clearMessages(); + const expectedSequenceId = session.getNextSeq(); + const expected = expectedGetErr(); + session.executeCommandSeq({ + command: protocol.CommandTypes.Geterr, + arguments: { + delay: 0, + files: expected.map(f => f.file.path) + } + }); + + checkAllErrors({ session, host, expected, expectedSequenceId }); + }); + } + + function verifyErrorsUsingGeterrForProject({ allFiles, openFiles, expectedGetErrForProject }: VerifyScenario) { + it("verifies the errors in projects", () => { + const host = createServerHost([...allFiles(), libFile]); + const session = createSession(host, { canUseEvents: true, }); + openFilesForSession(openFiles(), session); + + session.clearMessages(); + for (const expected of expectedGetErrForProject()) { + const expectedSequenceId = session.getNextSeq(); + session.executeCommandSeq({ + command: protocol.CommandTypes.GeterrForProject, + arguments: { + delay: 0, + file: expected.project + } + }); + + checkAllErrors({ session, host, expected: expected.errors, expectedSequenceId }); + } + }); + } + + function verifyErrorsUsingSyncMethods({ allFiles, openFiles, expectedSyncDiagnostics }: VerifyScenario) { + it("verifies the errors using sync commands", () => { + const host = createServerHost([...allFiles(), libFile]); + const session = createSession(host); + openFilesForSession(openFiles(), session); + for (const { file, project, syntax, semantic, suggestion } of expectedSyncDiagnostics()) { + const actualSyntax = session.executeCommandSeq({ + command: protocol.CommandTypes.SyntacticDiagnosticsSync, + arguments: { + file: file.path, + projectFileName: project + } + }).response as protocol.Diagnostic[]; + assert.deepEqual(actualSyntax, syntax, `Syntax diagnostics for file: ${file.path}, project: ${project}`); + const actualSemantic = session.executeCommandSeq({ + command: protocol.CommandTypes.SemanticDiagnosticsSync, + arguments: { + file: file.path, + projectFileName: project + } + }).response as protocol.Diagnostic[]; + assert.deepEqual(actualSemantic, semantic, `Semantic diagnostics for file: ${file.path}, project: ${project}`); + const actualSuggestion = session.executeCommandSeq({ + command: protocol.CommandTypes.SuggestionDiagnosticsSync, + arguments: { + file: file.path, + projectFileName: project + } + }).response as protocol.Diagnostic[]; + assert.deepEqual(actualSuggestion, suggestion, `Suggestion diagnostics for file: ${file.path}, project: ${project}`); + } + }); + } + + function verifyConfigFileErrors({ allFiles, openFiles, expectedConfigFileDiagEvents }: VerifyScenario) { + it("verify config file errors", () => { + const host = createServerHost([...allFiles(), libFile]); + const { session, events } = createSessionWithEventTracking(host, server.ConfigFileDiagEvent); + + for (const file of openFiles()) { + session.executeCommandSeq({ + command: protocol.CommandTypes.Open, + arguments: { file: file.path } + }); + } + + assert.deepEqual(events, expectedConfigFileDiagEvents().map(data => ({ + eventName: server.ConfigFileDiagEvent, + data + }))); + }); + } + + interface GetErrDiagnostics { + file: File; + syntax: protocol.Diagnostic[]; + semantic: protocol.Diagnostic[]; + suggestion: protocol.Diagnostic[]; + } + interface GetErrForProjectDiagnostics { + project: string; + errors: readonly GetErrDiagnostics[]; + } + interface SyncDiagnostics extends GetErrDiagnostics { + project?: string; + } + interface VerifyScenario { + allFiles: () => readonly File[]; + openFiles: () => readonly File[]; + expectedGetErr: () => readonly GetErrDiagnostics[]; + expectedGetErrForProject: () => readonly GetErrForProjectDiagnostics[]; + expectedSyncDiagnostics: () => readonly SyncDiagnostics[]; + expectedConfigFileDiagEvents: () => readonly server.ConfigFileDiagEvent["data"][]; + } + function verifyScenario(scenario: VerifyScenario) { + verifyErrorsUsingGeterr(scenario); + verifyErrorsUsingGeterrForProject(scenario); + verifyErrorsUsingSyncMethods(scenario); + verifyConfigFileErrors(scenario); + } + + function emptyDiagnostics(file: File): GetErrDiagnostics { + return { + file, + syntax: emptyArray, + semantic: emptyArray, + suggestion: emptyArray + }; + } + + function syncDiagnostics(diagnostics: GetErrDiagnostics, project: string): SyncDiagnostics { + return { project, ...diagnostics }; + } + + interface VerifyUsageAndDependency { + allFiles: readonly [File, File, File, File]; // dependencyTs, dependencyConfig, usageTs, usageConfig + usageDiagnostics(): GetErrDiagnostics; + dependencyDiagnostics(): GetErrDiagnostics; + + } + function verifyUsageAndDependency({ allFiles, usageDiagnostics, dependencyDiagnostics }: VerifyUsageAndDependency) { + const [dependencyTs, dependencyConfig, usageTs, usageConfig] = allFiles; + function usageProjectDiagnostics(): GetErrForProjectDiagnostics { + return { + project: usageTs.path, + errors: [ + usageDiagnostics(), + emptyDiagnostics(dependencyTs) + ] + }; + } + + function dependencyProjectDiagnostics(): GetErrForProjectDiagnostics { + return { + project: dependencyTs.path, + errors: [ + dependencyDiagnostics() + ] + }; + } + + function usageConfigDiag(): server.ConfigFileDiagEvent["data"] { + return { + triggerFile: usageTs.path, + configFileName: usageConfig.path, + diagnostics: emptyArray + }; + } + + function dependencyConfigDiag(): server.ConfigFileDiagEvent["data"] { + return { + triggerFile: dependencyTs.path, + configFileName: dependencyConfig.path, + diagnostics: emptyArray + }; + } + + describe("when dependency project is not open", () => { + verifyScenario({ + allFiles: () => allFiles, + openFiles: () => [usageTs], + expectedGetErr: () => [ + usageDiagnostics() + ], + expectedGetErrForProject: () => [ + usageProjectDiagnostics(), + { + project: dependencyTs.path, + errors: [ + emptyDiagnostics(dependencyTs), + usageDiagnostics() + ] + } + ], + expectedSyncDiagnostics: () => [ + // Without project + usageDiagnostics(), + emptyDiagnostics(dependencyTs), + // With project + syncDiagnostics(usageDiagnostics(), usageConfig.path), + syncDiagnostics(emptyDiagnostics(dependencyTs), usageConfig.path), + ], + expectedConfigFileDiagEvents: () => [ + usageConfigDiag() + ], + }); + }); + + describe("when the depedency file is open", () => { + verifyScenario({ + allFiles: () => allFiles, + openFiles: () => [usageTs, dependencyTs], + expectedGetErr: () => [ + usageDiagnostics(), + dependencyDiagnostics(), + ], + expectedGetErrForProject: () => [ + usageProjectDiagnostics(), + dependencyProjectDiagnostics() + ], + expectedSyncDiagnostics: () => [ + // Without project + usageDiagnostics(), + dependencyDiagnostics(), + // With project + syncDiagnostics(usageDiagnostics(), usageConfig.path), + syncDiagnostics(emptyDiagnostics(dependencyTs), usageConfig.path), + syncDiagnostics(dependencyDiagnostics(), dependencyConfig.path), + ], + expectedConfigFileDiagEvents: () => [ + usageConfigDiag(), + dependencyConfigDiag() + ], + }); + }); + } + + describe("with module scenario", () => { + const dependencyTs: File = { + path: `${dependecyLocation}/fns.ts`, + content: `export function fn1() { } +export function fn2() { } +// Introduce error for fnErr import in main +// export function fnErr() { } +// Error in dependency ts file +export let x: string = 10;` + }; + const dependencyConfig: File = { + path: `${dependecyLocation}/tsconfig.json`, + content: JSON.stringify({ compilerOptions: { composite: true, declarationDir: "../decls" } }) + }; + const usageTs: File = { + path: `${usageLocation}/usage.ts`, + content: `import { + fn1, + fn2, + fnErr +} from '../decls/fns' +fn1(); +fn2(); +fnErr(); +` + }; + const usageConfig: File = { + path: `${usageLocation}/tsconfig.json`, + content: JSON.stringify({ + compilerOptions: { composite: true }, + references: [{ path: "../dependency" }] + }) + }; + function usageDiagnostics(): GetErrDiagnostics { + return { + file: usageTs, + syntax: emptyArray, + semantic: [ + createDiagnostic( + { line: 4, offset: 5 }, + { line: 4, offset: 10 }, + Diagnostics.Module_0_has_no_exported_member_1, + [`"../dependency/fns"`, "fnErr"], + "error", + ) + ], + suggestion: emptyArray + }; + } + + function dependencyDiagnostics(): GetErrDiagnostics { + return { + file: dependencyTs, + syntax: emptyArray, + semantic: [ + createDiagnostic( + { line: 6, offset: 12 }, + { line: 6, offset: 13 }, + Diagnostics.Type_0_is_not_assignable_to_type_1, + ["10", "string"], + "error", + ) + ], + suggestion: emptyArray + }; + } + + verifyUsageAndDependency({ + allFiles: [dependencyTs, dependencyConfig, usageTs, usageConfig], + usageDiagnostics, + dependencyDiagnostics + }); + }); + + describe("with non module --out", () => { + const dependencyTs: File = { + path: `${dependecyLocation}/fns.ts`, + content: `function fn1() { } +function fn2() { } +// Introduce error for fnErr import in main +// function fnErr() { } +// Error in dependency ts file +let x: string = 10;` + }; + const dependencyConfig: File = { + path: `${dependecyLocation}/tsconfig.json`, + content: JSON.stringify({ compilerOptions: { composite: true, outFile: "../dependency.js" } }) + }; + const usageTs: File = { + path: `${usageLocation}/usage.ts`, + content: `fn1(); +fn2(); +fnErr(); +` + }; + const usageConfig: File = { + path: `${usageLocation}/tsconfig.json`, + content: JSON.stringify({ + compilerOptions: { composite: true, outFile: "../usage.js" }, + references: [{ path: "../dependency" }] + }) + }; + function usageDiagnostics(): GetErrDiagnostics { + return { + file: usageTs, + syntax: emptyArray, + semantic: [ + createDiagnostic( + { line: 3, offset: 1 }, + { line: 3, offset: 6 }, + Diagnostics.Cannot_find_name_0, + ["fnErr"], + "error", + ) + ], + suggestion: emptyArray + }; + } + + function dependencyDiagnostics(): GetErrDiagnostics { + return { + file: dependencyTs, + syntax: emptyArray, + semantic: [ + createDiagnostic( + { line: 6, offset: 5 }, + { line: 6, offset: 6 }, + Diagnostics.Type_0_is_not_assignable_to_type_1, + ["10", "string"], + "error", + ) + ], + suggestion: emptyArray + }; + } + + verifyUsageAndDependency({ + allFiles: [dependencyTs, dependencyConfig, usageTs, usageConfig], + usageDiagnostics, + dependencyDiagnostics + }); + }); + }); +} diff --git a/src/testRunner/unittests/tsserver/projectReferences.ts b/src/testRunner/unittests/tsserver/projectReferences.ts index 7db9d755b26..2e886e2169e 100644 --- a/src/testRunner/unittests/tsserver/projectReferences.ts +++ b/src/testRunner/unittests/tsserver/projectReferences.ts @@ -85,8 +85,8 @@ namespace ts.projectSystem { }); const { file: _, ...renameTextOfMyConstInLib } = locationOfMyConstInLib; assert.deepEqual(response.locs, [ - { file: myConstFile, locs: [{ start: myConstStart, end: myConstEnd }] }, - { file: locationOfMyConstInLib.file, locs: [renameTextOfMyConstInLib] } + { file: locationOfMyConstInLib.file, locs: [renameTextOfMyConstInLib] }, + { file: myConstFile, locs: [{ start: myConstStart, end: myConstEnd }] } ]); }); }); @@ -105,6 +105,7 @@ export function fn4() { } export function fn5() { } ` }; + const dependencyTsPath = dependencyTs.path.toLowerCase(); const dependencyConfig: File = { path: `${dependecyLocation}/tsconfig.json`, content: JSON.stringify({ compilerOptions: { composite: true, declarationMap: true, declarationDir: "../decls" } }) @@ -150,59 +151,17 @@ fn5(); const files = [dependencyTs, dependencyConfig, mainTs, mainConfig, libFile, randomFile, randomConfig]; - function verifyScriptInfos(session: TestSession, host: TestServerHost, openInfos: readonly string[], closedInfos: readonly string[], otherWatchedFiles: readonly string[]) { - checkScriptInfos(session.getProjectService(), openInfos.concat(closedInfos)); - checkWatchedFiles(host, closedInfos.concat(otherWatchedFiles).map(f => f.toLowerCase())); + function verifyScriptInfos(session: TestSession, host: TestServerHost, openInfos: readonly string[], closedInfos: readonly string[], otherWatchedFiles: readonly string[], additionalInfo: string) { + checkScriptInfos(session.getProjectService(), openInfos.concat(closedInfos), additionalInfo); + checkWatchedFiles(host, closedInfos.concat(otherWatchedFiles).map(f => f.toLowerCase()), additionalInfo); } - function verifyInfosWithRandom(session: TestSession, host: TestServerHost, openInfos: readonly string[], closedInfos: readonly string[], otherWatchedFiles: readonly string[]) { - verifyScriptInfos(session, host, openInfos.concat(randomFile.path), closedInfos, otherWatchedFiles.concat(randomConfig.path)); + function verifyInfosWithRandom(session: TestSession, host: TestServerHost, openInfos: readonly string[], closedInfos: readonly string[], otherWatchedFiles: readonly string[], reqName: string) { + verifyScriptInfos(session, host, openInfos.concat(randomFile.path), closedInfos, otherWatchedFiles.concat(randomConfig.path), reqName); } function verifyOnlyRandomInfos(session: TestSession, host: TestServerHost) { - verifyScriptInfos(session, host, [randomFile.path], [libFile.path], [randomConfig.path]); - } - - // Returns request and expected Response, expected response when no map file - interface SessionAction { - reqName: string; - request: Partial; - expectedResponse: Response; - expectedResponseNoMap?: Response; - expectedResponseNoDts?: Response; - } - function gotoDefintinionFromMainTs(fn: number): SessionAction { - const textSpan = usageSpan(fn); - const definition: protocol.FileSpan = { file: dependencyTs.path, ...declarationSpan(fn) }; - const declareSpaceLength = "declare ".length; - return { - reqName: "goToDef", - request: { - command: protocol.CommandTypes.DefinitionAndBoundSpan, - arguments: { file: mainTs.path, ...textSpan.start } - }, - expectedResponse: { - // To dependency - definitions: [definition], - textSpan - }, - expectedResponseNoMap: { - // To the dts - definitions: [{ - file: dtsPath, - start: { line: fn, offset: definition.start.offset + declareSpaceLength }, - end: { line: fn, offset: definition.end.offset + declareSpaceLength }, - contextStart: { line: fn, offset: 1 }, - contextEnd: { line: fn, offset: 37 } - }], - textSpan - }, - expectedResponseNoDts: { - // To import declaration - definitions: [{ file: mainTs.path, ...importSpan(fn) }], - textSpan - } - }; + verifyScriptInfos(session, host, [randomFile.path], [libFile.path], [randomConfig.path], "Random"); } function declarationSpan(fn: number): protocol.TextSpanWithContext { @@ -225,7 +184,91 @@ fn5(); return { start: { line: fn + 8, offset: 1 }, end: { line: fn + 8, offset: 4 } }; } - function renameFromDependencyTs(fn: number): SessionAction { + function goToDefFromMainTs(fn: number): Action { + const textSpan = usageSpan(fn); + const definition: protocol.FileSpan = { file: dependencyTs.path, ...declarationSpan(fn) }; + return { + reqName: "goToDef", + request: { + command: protocol.CommandTypes.DefinitionAndBoundSpan, + arguments: { file: mainTs.path, ...textSpan.start } + }, + expectedResponse: { + // To dependency + definitions: [definition], + textSpan + } + }; + } + + function goToDefFromMainTsWithNoMap(fn: number): Action { + const textSpan = usageSpan(fn); + const definition = declarationSpan(fn); + const declareSpaceLength = "declare ".length; + return { + reqName: "goToDef", + request: { + command: protocol.CommandTypes.DefinitionAndBoundSpan, + arguments: { file: mainTs.path, ...textSpan.start } + }, + expectedResponse: { + // To the dts + definitions: [{ + file: dtsPath, + start: { line: fn, offset: definition.start.offset + declareSpaceLength }, + end: { line: fn, offset: definition.end.offset + declareSpaceLength }, + contextStart: { line: fn, offset: 1 }, + contextEnd: { line: fn, offset: 37 } + }], + textSpan + } + }; + } + + function goToDefFromMainTsWithNoDts(fn: number): Action { + const textSpan = usageSpan(fn); + return { + reqName: "goToDef", + request: { + command: protocol.CommandTypes.DefinitionAndBoundSpan, + arguments: { file: mainTs.path, ...textSpan.start } + }, + expectedResponse: { + // To import declaration + definitions: [{ file: mainTs.path, ...importSpan(fn) }], + textSpan + } + }; + } + + function goToDefFromMainTsWithDependencyChange(fn: number): Action { + const textSpan = usageSpan(fn); + return { + reqName: "goToDef", + request: { + command: protocol.CommandTypes.DefinitionAndBoundSpan, + arguments: { file: mainTs.path, ...textSpan.start } + }, + expectedResponse: { + // Definition on fn + 1 line + definitions: [{ file: dependencyTs.path, ...declarationSpan(fn + 1) }], + textSpan + } + }; + } + + function goToDefFromMainTsProjectInfoVerifier(withRefs: boolean): ProjectInfoVerifier { + return { + openFile: mainTs, + openFileLastLine: 14, + configFile: mainConfig, + expectedProjectActualFiles: withRefs ? + [mainTs.path, libFile.path, mainConfig.path, dependencyTs.path] : + [mainTs.path, libFile.path, mainConfig.path, dtsPath] + }; + } + + function renameFromDependencyTs(fn: number): Action { const defSpan = declarationSpan(fn); const { contextStart: _, contextEnd: _1, ...triggerSpan } = defSpan; return { @@ -251,7 +294,32 @@ fn5(); }; } - function renameFromDependencyTsWithBothProjectsOpen(fn: number): SessionAction { + function renameFromDependencyTsWithDependencyChange(fn: number): Action { + const { expectedResponse: { info, locs }, ...rest } = renameFromDependencyTs(fn + 1); + + return { + ...rest, + expectedResponse: { + info: { + ...info as protocol.RenameInfoSuccess, + displayName: `fn${fn}`, + fullDisplayName: `"${dependecyLocation}/FnS".fn${fn}`, + }, + locs + } + }; + } + + function renameFromDependencyTsProjectInfoVerifier(): ProjectInfoVerifier { + return { + openFile: dependencyTs, + openFileLastLine: 6, + configFile: dependencyConfig, + expectedProjectActualFiles: [dependencyTs.path, libFile.path, dependencyConfig.path] + }; + } + + function renameFromDependencyTsWithBothProjectsOpen(fn: number): Action { const { reqName, request, expectedResponse } = renameFromDependencyTs(fn); const { info, locs } = expectedResponse; return { @@ -269,442 +337,846 @@ fn5(); ] } ] - }, - // Only dependency result - expectedResponseNoMap: expectedResponse, - expectedResponseNoDts: expectedResponse + } }; } - // Returns request and expected Response - type SessionActionGetter = (fn: number) => SessionAction; - // Open File, expectedProjectActualFiles, actionGetter, openFileLastLine - interface DocumentPositionMapperVerifier { - openFile: File; - expectedProjectActualFiles: readonly string[]; - actionGetter: SessionActionGetter; - openFileLastLine: number; + function renameFromDependencyTsWithBothProjectsOpenWithDependencyChange(fn: number): Action { + const { reqName, request, expectedResponse, } = renameFromDependencyTsWithDependencyChange(fn); + const { info, locs } = expectedResponse; + return { + reqName, + request, + expectedResponse: { + info, + locs: [ + locs[0], + { + file: mainTs.path, + locs: [ + importSpan(fn), + usageSpan(fn) + ] + } + ] + } + }; } - function verifyDocumentPositionMapperUpdates( - mainScenario: string, - verifier: readonly DocumentPositionMapperVerifier[], - closedInfos: readonly string[], - withRefs: boolean) { - const openFiles = verifier.map(v => v.openFile); - const expectedProjectActualFiles = verifier.map(v => v.expectedProjectActualFiles); - const openFileLastLines = verifier.map(v => v.openFileLastLine); + function removePath(array: readonly string[], ...delPaths: string[]) { + return array.filter(a => { + const aLower = a.toLowerCase(); + return delPaths.every(dPath => dPath !== aLower); + }); + } - const configFiles = openFiles.map(openFile => `${getDirectoryPath(openFile.path)}/tsconfig.json`); - const openInfos = openFiles.map(f => f.path); - // When usage and dependency are used, dependency config is part of closedInfo so ignore - const otherWatchedFiles = withRefs && verifier.length > 1 ? [configFiles[0]] : configFiles; - function openTsFile(onHostCreate?: (host: TestServerHost) => void) { - const host = createHost(files, [mainConfig.path]); - if (!withRefs) { - // Erase project reference - host.writeFile(mainConfig.path, JSON.stringify({ - compilerOptions: { composite: true, declarationMap: true } - })); - } - if (onHostCreate) { - onHostCreate(host); - } - const session = createSession(host); - openFilesForSession([...openFiles, randomFile], session); - return { host, session }; + interface Action { + reqName: string; + request: Partial; + expectedResponse: Response; + } + interface ActionInfo { + action: (fn: number) => Action; + closedInfos: readonly string[]; + otherWatchedFiles: readonly string[]; + expectsDts: boolean; + expectsMap: boolean; + freshMapInfo?: boolean; + freshDocumentMapper?: boolean; + skipDtsMapCheck?: boolean; + } + type ActionKey = keyof ActionInfoVerifier; + type ActionInfoGetterFn = () => ActionInfo; + type ActionInfoSpreader = [ + ActionKey, // Key to get initial value and pass this value to spread function + (actionInfo: ActionInfo) => Partial> + ]; + type ActionInfoGetter = ActionInfoGetterFn | ActionKey | ActionInfoSpreader; + interface ProjectInfoVerifier { + openFile: File; + openFileLastLine: number; + configFile: File; + expectedProjectActualFiles: readonly string[]; + } + interface ActionInfoVerifier { + main: ActionInfoGetter; + change: ActionInfoGetter; + dtsChange: ActionInfoGetter; + mapChange: ActionInfoGetter; + noMap: ActionInfoGetter; + mapFileCreated: ActionInfoGetter; + mapFileDeleted: ActionInfoGetter; + noDts: ActionInfoGetter; + dtsFileCreated: ActionInfoGetter; + dtsFileDeleted: ActionInfoGetter; + dependencyChange: ActionInfoGetter; + noBuild: ActionInfoGetter; + } + interface DocumentPositionMapperVerifier extends ProjectInfoVerifier, ActionInfoVerifier { + } + + interface VerifierAndWithRefs { + withRefs: boolean; + disableSourceOfProjectReferenceRedirect?: true; + verifier: (withRefs: boolean) => readonly DocumentPositionMapperVerifier[]; + } + + function openFiles(verifiers: readonly DocumentPositionMapperVerifier[]) { + return verifiers.map(v => v.openFile); + } + interface OpenTsFile extends VerifierAndWithRefs { + onHostCreate?: (host: TestServerHost) => void; + } + function openTsFile({ withRefs, disableSourceOfProjectReferenceRedirect, verifier, onHostCreate }: OpenTsFile) { + const host = createHost(files, [mainConfig.path]); + if (!withRefs) { + // Erase project reference + host.writeFile(mainConfig.path, JSON.stringify({ + compilerOptions: { composite: true, declarationMap: true } + })); } - - function checkProject(session: TestSession, noDts?: true) { - const service = session.getProjectService(); - checkNumberOfProjects(service, { configuredProjects: 1 + verifier.length }); - configFiles.forEach((configFile, index) => { - checkProjectActualFiles( - service.configuredProjects.get(configFile)!, - noDts ? - expectedProjectActualFiles[index].filter(f => f.toLowerCase() !== dtsPath) : - expectedProjectActualFiles[index] - ); - }); + else if (disableSourceOfProjectReferenceRedirect) { + // Erase project reference + host.writeFile(mainConfig.path, JSON.stringify({ + compilerOptions: { + composite: true, + declarationMap: true, + disableSourceOfProjectReferenceRedirect: !!disableSourceOfProjectReferenceRedirect + }, + references: [{ path: "../dependency" }] + })); } - - function verifyInfos(session: TestSession, host: TestServerHost) { - verifyInfosWithRandom(session, host, openInfos, closedInfos, otherWatchedFiles); + if (onHostCreate) { + onHostCreate(host); } + const session = createSession(host); + const verifiers = verifier(withRefs && !disableSourceOfProjectReferenceRedirect); + openFilesForSession([...openFiles(verifiers), randomFile], session); + return { host, session, verifiers }; + } - function verifyInfosWhenNoMapFile(session: TestSession, host: TestServerHost, dependencyTsOK?: true) { - const dtsMapClosedInfo = firstDefined(closedInfos, f => f.toLowerCase() === dtsMapPath ? f : undefined); - verifyInfosWithRandom( - session, - host, - openInfos, - closedInfos.filter(f => f !== dtsMapClosedInfo && (dependencyTsOK || f !== dependencyTs.path)), - dtsMapClosedInfo ? otherWatchedFiles.concat(dtsMapClosedInfo) : otherWatchedFiles + function checkProject(session: TestSession, verifiers: readonly DocumentPositionMapperVerifier[], noDts?: true) { + const service = session.getProjectService(); + checkNumberOfProjects(service, { configuredProjects: 1 + verifiers.length }); + verifiers.forEach(({ configFile, expectedProjectActualFiles }) => { + checkProjectActualFiles( + service.configuredProjects.get(configFile.path.toLowerCase())!, + noDts ? + expectedProjectActualFiles.filter(f => f.toLowerCase() !== dtsPath) : + expectedProjectActualFiles ); - } + }); + } - function verifyInfosWhenNoDtsFile(session: TestSession, host: TestServerHost, watchDts: boolean, dependencyTsAndMapOk?: true) { - const dtsMapClosedInfo = firstDefined(closedInfos, f => f.toLowerCase() === dtsMapPath ? f : undefined); - const dtsClosedInfo = firstDefined(closedInfos, f => f.toLowerCase() === dtsPath ? f : undefined); - verifyInfosWithRandom( - session, - host, - openInfos, - closedInfos.filter(f => (dependencyTsAndMapOk || f !== dtsMapClosedInfo) && f !== dtsClosedInfo && (dependencyTsAndMapOk || f !== dependencyTs.path)), - dtsClosedInfo && watchDts ? - otherWatchedFiles.concat(dtsClosedInfo) : - otherWatchedFiles - ); + function firstAction(session: TestSession, verifiers: readonly DocumentPositionMapperVerifier[]) { + for (const { action } of getActionInfo(verifiers, "main")) { + const { request } = action(1); + session.executeCommandSeq(request); } + } - function verifyDocumentPositionMapper(session: TestSession, dependencyMap: server.ScriptInfo, documentPositionMapper: server.ScriptInfo["documentPositionMapper"], notEqual?: true) { - assert.strictEqual(session.getProjectService().filenameToScriptInfo.get(dtsMapPath), dependencyMap); - if (notEqual) { - assert.notStrictEqual(dependencyMap.documentPositionMapper, documentPositionMapper); + function verifyAction(session: TestSession, { reqName, request, expectedResponse }: Action) { + const { response } = session.executeCommandSeq(request); + assert.deepEqual(response, expectedResponse, `Failed Request: ${reqName}`); + } + + function verifyScriptInfoPresence(session: TestSession, path: string, expectedToBePresent: boolean, reqName: string) { + const info = session.getProjectService().filenameToScriptInfo.get(path); + if (expectedToBePresent) { + assert.isDefined(info, `${reqName}:: ${path} expected to be present`); + } + else { + assert.isUndefined(info, `${reqName}:: ${path} expected to be not present`); + } + return info; + } + + interface VerifyDocumentPositionMapper { + session: TestSession; + dependencyMap: server.ScriptInfo | undefined; + documentPositionMapper: server.ScriptInfo["documentPositionMapper"]; + equal: boolean; + debugInfo: string; + } + function verifyDocumentPositionMapper({ session, dependencyMap, documentPositionMapper, equal, debugInfo }: VerifyDocumentPositionMapper) { + assert.strictEqual(session.getProjectService().filenameToScriptInfo.get(dtsMapPath), dependencyMap, debugInfo); + if (dependencyMap) { + if (equal) { + assert.strictEqual(dependencyMap.documentPositionMapper, documentPositionMapper, debugInfo); } else { - assert.strictEqual(dependencyMap.documentPositionMapper, documentPositionMapper); + assert.notStrictEqual(dependencyMap.documentPositionMapper, documentPositionMapper, debugInfo); } } + } - function action(verifier: DocumentPositionMapperVerifier, fn: number, session: TestSession) { - const { reqName, request, expectedResponse, expectedResponseNoMap, expectedResponseNoDts } = verifier.actionGetter(fn); - const { response } = session.executeCommandSeq(request); - return { reqName, response, expectedResponse, expectedResponseNoMap, expectedResponseNoDts, verifier }; + function getActionInfoOfVerfier(verifier: DocumentPositionMapperVerifier, actionKey: ActionKey): ActionInfo { + const actionInfoGetter = verifier[actionKey]; + if (isString(actionInfoGetter)) { + return getActionInfoOfVerfier(verifier, actionInfoGetter); } - function firstAction(session: TestSession) { - verifier.forEach(v => action(v, 1, session)); + if (isArray(actionInfoGetter)) { + const initialValue = getActionInfoOfVerfier(verifier, actionInfoGetter[0]); + return { + ...initialValue, + ...actionInfoGetter[1](initialValue) + }; } - function verifyAllFnActionWorker(session: TestSession, verifyAction: (result: ReturnType, dtsInfo: server.ScriptInfo | undefined, isFirst: boolean) => void, dtsAbsent?: true) { - // action - let isFirst = true; - for (const v of verifier) { - for (let fn = 1; fn <= 5; fn++) { - const result = action(v, fn, session); - const dtsInfo = session.getProjectService().filenameToScriptInfo.get(dtsPath); - if (dtsAbsent) { - assert.isUndefined(dtsInfo); - } - else { - assert.isDefined(dtsInfo); - } - verifyAction(result, dtsInfo, isFirst); - isFirst = false; - } - } - } + return actionInfoGetter(); + } - function verifyAllFnAction( - session: TestSession, - host: TestServerHost, - firstDocumentPositionMapperNotEquals?: true, - dependencyMap?: server.ScriptInfo, - documentPositionMapper?: server.ScriptInfo["documentPositionMapper"] - ) { - // action - verifyAllFnActionWorker(session, ({ reqName, response, expectedResponse }, dtsInfo, isFirst) => { - assert.deepEqual(response, expectedResponse, `Failed on ${reqName}`); - verifyInfos(session, host); - assert.equal(dtsInfo!.sourceMapFilePath, dtsMapPath); - if (isFirst) { - if (dependencyMap) { - verifyDocumentPositionMapper(session, dependencyMap, documentPositionMapper, firstDocumentPositionMapperNotEquals); - documentPositionMapper = dependencyMap.documentPositionMapper; - } - else { - dependencyMap = session.getProjectService().filenameToScriptInfo.get(dtsMapPath)!; - documentPositionMapper = dependencyMap.documentPositionMapper; - } - } - else { - verifyDocumentPositionMapper(session, dependencyMap!, documentPositionMapper); - } - }); - return { dependencyMap: dependencyMap!, documentPositionMapper }; - } + function getActionInfo(verifiers: readonly DocumentPositionMapperVerifier[], actionKey: ActionKey): ActionInfo[] { + return verifiers.map(v => getActionInfoOfVerfier(v, actionKey)); + } - function verifyAllFnActionWithNoMap( - session: TestSession, - host: TestServerHost, - dependencyTsOK?: true - ) { - let sourceMapFilePath: server.ScriptInfo["sourceMapFilePath"]; - // action - verifyAllFnActionWorker(session, ({ reqName, response, expectedResponse, expectedResponseNoMap }, dtsInfo, isFirst) => { - assert.deepEqual(response, expectedResponseNoMap || expectedResponse, `Failed on ${reqName}`); - verifyInfosWhenNoMapFile(session, host, dependencyTsOK); - assert.isUndefined(session.getProjectService().filenameToScriptInfo.get(dtsMapPath)); - if (isFirst) { - assert.isNotString(dtsInfo!.sourceMapFilePath); - assert.isNotFalse(dtsInfo!.sourceMapFilePath); - assert.isDefined(dtsInfo!.sourceMapFilePath); - sourceMapFilePath = dtsInfo!.sourceMapFilePath; - } - else { - assert.equal(dtsInfo!.sourceMapFilePath, sourceMapFilePath); - } - }); - return sourceMapFilePath; - } - - function verifyAllFnActionWithNoDts( - session: TestSession, - host: TestServerHost, - dependencyTsAndMapOk?: true - ) { - // action - verifyAllFnActionWorker(session, ({ reqName, response, expectedResponse, expectedResponseNoDts, verifier }) => { - assert.deepEqual(response, expectedResponseNoDts || expectedResponse, `Failed on ${reqName}`); - verifyInfosWhenNoDtsFile( + interface VerifyAllFnAction { + session: TestSession; + host: TestServerHost; + verifiers: readonly DocumentPositionMapperVerifier[]; + actionKey: ActionKey; + sourceMapPath?: server.ScriptInfo["sourceMapFilePath"]; + dependencyMap?: server.ScriptInfo | undefined; + documentPositionMapper?: server.ScriptInfo["documentPositionMapper"]; + } + interface VerifyAllFnActionResult { + actionInfos: readonly ActionInfo[]; + actionKey: ActionKey; + dependencyMap: server.ScriptInfo | undefined; + documentPositionMapper: server.ScriptInfo["documentPositionMapper"] | undefined; + } + function verifyAllFnAction({ + session, + host, + verifiers, + actionKey, + dependencyMap, + documentPositionMapper, + }: VerifyAllFnAction): VerifyAllFnActionResult { + const actionInfos = getActionInfo(verifiers, actionKey); + let sourceMapPath: server.ScriptInfo["sourceMapFilePath"] | undefined; + // action + let first = true; + for (const { + action, + closedInfos, + otherWatchedFiles, + expectsDts, + expectsMap, + freshMapInfo, + freshDocumentMapper, + skipDtsMapCheck + } of actionInfos) { + for (let fn = 1; fn <= 5; fn++) { + const fnAction = action(fn); + verifyAction(session, fnAction); + const debugInfo = `${actionKey}:: ${fnAction.reqName}:: ${fn}`; + const dtsInfo = verifyScriptInfoPresence(session, dtsPath, expectsDts, debugInfo); + const dtsMapInfo = verifyScriptInfoPresence(session, dtsMapPath, expectsMap, debugInfo); + verifyInfosWithRandom( session, host, - // Even when project actual file contains dts, its not watched because the dts is in another folder and module resolution just fails - // instead of succeeding to source file and then mapping using project reference (When using usage location) - // But watched if sourcemapper is in source project since we need to keep track of dts to update the source mapper for any potential usages - verifier.expectedProjectActualFiles.every(f => f.toLowerCase() !== dtsPath), - dependencyTsAndMapOk, + openFiles(verifiers).map(f => f.path), + closedInfos, + otherWatchedFiles, + debugInfo ); - }, /*dtsAbsent*/ true); + + if (dtsInfo) { + if (first || (fn === 1 && freshMapInfo)) { + if (!skipDtsMapCheck) { + if (dtsMapInfo) { + assert.equal(dtsInfo.sourceMapFilePath, dtsMapPath, debugInfo); + } + else { + assert.isNotString(dtsInfo.sourceMapFilePath, debugInfo); + assert.isNotFalse(dtsInfo.sourceMapFilePath, debugInfo); + assert.isDefined(dtsInfo.sourceMapFilePath, debugInfo); + } + } + } + else { + assert.equal(dtsInfo.sourceMapFilePath, sourceMapPath, debugInfo); + } + } + + if (!first && (fn !== 1 || !freshMapInfo)) { + verifyDocumentPositionMapper({ + session, + dependencyMap, + documentPositionMapper, + equal: fn !== 1 || !freshDocumentMapper, + debugInfo + }); + } + sourceMapPath = dtsInfo && dtsInfo.sourceMapFilePath; + dependencyMap = dtsMapInfo; + documentPositionMapper = dependencyMap && dependencyMap.documentPositionMapper; + first = false; + } } - function verifyScenarioWithChangesWorker( - change: (host: TestServerHost, session: TestSession) => void, - afterActionDocumentPositionMapperNotEquals: true | undefined, - timeoutBeforeAction: boolean - ) { - const { host, session } = openTsFile(); + return { actionInfos, actionKey, dependencyMap, documentPositionMapper }; + } + + function verifyScriptInfoCollection( + session: TestSession, + host: TestServerHost, + verifiers: readonly DocumentPositionMapperVerifier[], + { dependencyMap, documentPositionMapper, actionInfos, actionKey }: VerifyAllFnActionResult + ) { + // Collecting at this point retains dependency.d.ts and map + closeFilesForSession([randomFile], session); + openFilesForSession([randomFile], session); + + const { closedInfos, otherWatchedFiles } = last(actionInfos); + const debugInfo = `${actionKey} Collection`; + verifyInfosWithRandom( + session, + host, + openFiles(verifiers).map(f => f.path), + closedInfos, + otherWatchedFiles, + debugInfo + ); + verifyDocumentPositionMapper({ + session, + dependencyMap, + documentPositionMapper, + equal: true, + debugInfo + }); + + // Closing open file, removes dependencies too + closeFilesForSession([...openFiles(verifiers), randomFile], session); + openFilesForSession([randomFile], session); + verifyOnlyRandomInfos(session, host); + } + + function verifyScenarioAndScriptInfoCollection( + session: TestSession, + host: TestServerHost, + verifiers: readonly DocumentPositionMapperVerifier[], + actionKey: ActionKey, + noDts?: true + ) { + // Main scenario action + const result = verifyAllFnAction({ session, host, verifiers, actionKey }); + checkProject(session, verifiers, noDts); + verifyScriptInfoCollection(session, host, verifiers, result); + } + + function verifyScenarioWithChangesWorker( + { + scenarioName, + verifier, + withRefs, + change, + afterChangeActionKey + }: VerifyScenarioWithChanges, + timeoutBeforeAction: boolean, + ) { + it(scenarioName, () => { + const { host, session, verifiers } = openTsFile({ verifier, withRefs }); // Create DocumentPositionMapper - firstAction(session); - const dependencyMap = session.getProjectService().filenameToScriptInfo.get(dtsMapPath)!; - const documentPositionMapper = dependencyMap.documentPositionMapper; + firstAction(session, verifiers); + const dependencyMap = session.getProjectService().filenameToScriptInfo.get(dtsMapPath); + const documentPositionMapper = dependencyMap && dependencyMap.documentPositionMapper; // change - change(host, session); + change(host, session, verifiers); if (timeoutBeforeAction) { host.runQueuedTimeoutCallbacks(); - checkProject(session); - verifyDocumentPositionMapper(session, dependencyMap, documentPositionMapper); + checkProject(session, verifiers); + verifyDocumentPositionMapper({ + session, + dependencyMap, + documentPositionMapper, + equal: true, + debugInfo: "After change timeout" + }); } // action - verifyAllFnAction(session, host, afterActionDocumentPositionMapperNotEquals, dependencyMap, documentPositionMapper); - } - - function verifyScenarioWithChanges( - scenarioName: string, - change: (host: TestServerHost, session: TestSession) => void, - afterActionDocumentPositionMapperNotEquals?: true - ) { - describe(scenarioName, () => { - it("when timeout occurs before request", () => { - verifyScenarioWithChangesWorker(change, afterActionDocumentPositionMapperNotEquals, /*timeoutBeforeAction*/ true); - }); - - it("when timeout does not occur before request", () => { - verifyScenarioWithChangesWorker(change, afterActionDocumentPositionMapperNotEquals, /*timeoutBeforeAction*/ false); - }); - }); - } - - function verifyMainScenarioAndScriptInfoCollection(session: TestSession, host: TestServerHost) { - // Main scenario action - const { dependencyMap, documentPositionMapper } = verifyAllFnAction(session, host); - checkProject(session); - verifyInfos(session, host); - - // Collecting at this point retains dependency.d.ts and map - closeFilesForSession([randomFile], session); - openFilesForSession([randomFile], session); - verifyInfos(session, host); - verifyDocumentPositionMapper(session, dependencyMap, documentPositionMapper); - - // Closing open file, removes dependencies too - closeFilesForSession([...openFiles, randomFile], session); - openFilesForSession([randomFile], session); - verifyOnlyRandomInfos(session, host); - } - - function verifyMainScenarioAndScriptInfoCollectionWithNoMap(session: TestSession, host: TestServerHost, dependencyTsOKInScenario?: true) { - // Main scenario action - verifyAllFnActionWithNoMap(session, host, dependencyTsOKInScenario); - - // Collecting at this point retains dependency.d.ts and map watcher - closeFilesForSession([randomFile], session); - openFilesForSession([randomFile], session); - verifyInfosWhenNoMapFile(session, host); - - // Closing open file, removes dependencies too - closeFilesForSession([...openFiles, randomFile], session); - openFilesForSession([randomFile], session); - verifyOnlyRandomInfos(session, host); - } - - function verifyMainScenarioAndScriptInfoCollectionWithNoDts(session: TestSession, host: TestServerHost, dependencyTsAndMapOk?: true) { - // Main scenario action - verifyAllFnActionWithNoDts(session, host, dependencyTsAndMapOk); - - // Collecting at this point retains dependency.d.ts and map watcher - closeFilesForSession([randomFile], session); - openFilesForSession([randomFile], session); - verifyInfosWhenNoDtsFile( + verifyAllFnAction({ session, host, - !!forEach(verifier, v => v.expectedProjectActualFiles.every(f => f.toLowerCase() !== dtsPath)) - ); + verifiers, + actionKey: afterChangeActionKey, + dependencyMap, + documentPositionMapper + }); + }); + } - // Closing open file, removes dependencies too - closeFilesForSession([...openFiles, randomFile], session); - openFilesForSession([randomFile], session); - verifyOnlyRandomInfos(session, host); - } + interface VerifyScenarioWithChanges extends VerifierAndWithRefs { + scenarioName: string; + change: (host: TestServerHost, session: TestSession, verifiers: readonly DocumentPositionMapperVerifier[]) => void; + afterChangeActionKey: ActionKey; + } + function verifyScenarioWithChanges(verify: VerifyScenarioWithChanges) { + describe("when timeout occurs before request", () => { + verifyScenarioWithChangesWorker(verify, /*timeoutBeforeAction*/ true); + }); - function verifyScenarioWhenFileNotPresent( - scenarioName: string, - fileLocation: string, - verifyScenarioAndScriptInfoCollection: (session: TestSession, host: TestServerHost, dependencyTsOk?: true) => void, - noDts?: true - ) { - describe(scenarioName, () => { - it(mainScenario, () => { - const { host, session } = openTsFile(host => host.deleteFile(fileLocation)); - checkProject(session, noDts); + describe("when timeout does not occur before request", () => { + verifyScenarioWithChangesWorker(verify, /*timeoutBeforeAction*/ false); + }); + } - verifyScenarioAndScriptInfoCollection(session, host); + interface VerifyScenarioWhenFileNotPresent extends VerifierAndWithRefs { + scenarioName: string; + fileLocation: string; + fileNotPresentKey: ActionKey; + fileCreatedKey: ActionKey; + fileDeletedKey: ActionKey; + noDts?: true; + } + function verifyScenarioWhenFileNotPresent({ + scenarioName, + verifier, + withRefs, + fileLocation, + fileNotPresentKey, + fileCreatedKey, + fileDeletedKey, + noDts + }: VerifyScenarioWhenFileNotPresent) { + describe(scenarioName, () => { + it("when file is not present", () => { + const { host, session, verifiers } = openTsFile({ + verifier, + withRefs, + onHostCreate: host => host.deleteFile(fileLocation) }); + checkProject(session, verifiers, noDts); - it("when file is created", () => { - let fileContents: string | undefined; - const { host, session } = openTsFile(host => { + verifyScenarioAndScriptInfoCollection(session, host, verifiers, fileNotPresentKey, noDts); + }); + + it("when file is created after actions on projects", () => { + let fileContents: string | undefined; + const { host, session, verifiers } = openTsFile({ + verifier, + withRefs, + onHostCreate: host => { fileContents = host.readFile(fileLocation); host.deleteFile(fileLocation); - }); - firstAction(session); - - host.writeFile(fileLocation, fileContents!); - verifyMainScenarioAndScriptInfoCollection(session, host); + } }); + firstAction(session, verifiers); - it("when file is deleted", () => { - const { host, session } = openTsFile(); - firstAction(session); - - // The dependency file is deleted when orphan files are collected - host.deleteFile(fileLocation); - verifyScenarioAndScriptInfoCollection(session, host, /*dependencyTsOk*/ true); - }); + host.writeFile(fileLocation, fileContents!); + verifyScenarioAndScriptInfoCollection(session, host, verifiers, fileCreatedKey); }); - } + it("when file is deleted after actions on the projects", () => { + const { host, session, verifiers } = openTsFile({ verifier, withRefs }); + firstAction(session, verifiers); + + // The dependency file is deleted when orphan files are collected + host.deleteFile(fileLocation); + // Verify with deleted action key + verifyAllFnAction({ session, host, verifiers, actionKey: fileDeletedKey }); + checkProject(session, verifiers, noDts); + + // Script info collection should behave as fileNotPresentKey + verifyScriptInfoCollection( + session, + host, + verifiers, + { + actionInfos: getActionInfo(verifiers, fileNotPresentKey), + actionKey: fileNotPresentKey, + dependencyMap: undefined, + documentPositionMapper: undefined + } + ); + }); + }); + } + + function verifyScenarioWorker({ mainScenario, verifier }: VerifyScenario, withRefs: boolean, disableSourceOfProjectReferenceRedirect?: true) { it(mainScenario, () => { - const { host, session } = openTsFile(); - checkProject(session); - - verifyMainScenarioAndScriptInfoCollection(session, host); + const { host, session, verifiers } = openTsFile({ withRefs, disableSourceOfProjectReferenceRedirect, verifier }); + checkProject(session, verifiers); + verifyScenarioAndScriptInfoCollection(session, host, verifiers, "main"); }); // Edit - verifyScenarioWithChanges( - "when usage file changes, document position mapper doesnt change", - (_host, session) => openFiles.forEach( - (openFile, index) => session.executeCommandSeq({ + verifyScenarioWithChanges({ + scenarioName: "when usage file changes, document position mapper doesnt change", + verifier, + withRefs, + disableSourceOfProjectReferenceRedirect, + change: (_host, session, verifiers) => verifiers.forEach( + verifier => session.executeCommandSeq({ command: protocol.CommandTypes.Change, - arguments: { file: openFile.path, line: openFileLastLines[index], offset: 1, endLine: openFileLastLines[index], endOffset: 1, insertString: "const x = 10;" } + arguments: { + file: verifier.openFile.path, + line: verifier.openFileLastLine, + offset: 1, + endLine: verifier.openFileLastLine, + endOffset: 1, + insertString: "const x = 10;" + } }) - ) - ); + ), + afterChangeActionKey: "change" + }); // Edit dts to add new fn - verifyScenarioWithChanges( - "when dependency .d.ts changes, document position mapper doesnt change", - host => host.writeFile( + verifyScenarioWithChanges({ + scenarioName: "when dependency .d.ts changes, document position mapper doesnt change", + verifier, + withRefs, + disableSourceOfProjectReferenceRedirect, + change: host => host.writeFile( dtsLocation, host.readFile(dtsLocation)!.replace( "//# sourceMappingURL=FnS.d.ts.map", `export declare function fn6(): void; //# sourceMappingURL=FnS.d.ts.map` ) - ) - ); + ), + afterChangeActionKey: "dtsChange" + }); // Edit map file to represent added new line - verifyScenarioWithChanges( - "when dependency file's map changes", - host => host.writeFile( + verifyScenarioWithChanges({ + scenarioName: "when dependency file's map changes", + verifier, + withRefs, + disableSourceOfProjectReferenceRedirect, + change: host => host.writeFile( dtsMapLocation, `{"version":3,"file":"FnS.d.ts","sourceRoot":"","sources":["../dependency/FnS.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,wBAAgB,GAAG,SAAM;AACzB,eAAO,MAAM,CAAC,KAAK,CAAC"}` ), - /*afterActionDocumentPositionMapperNotEquals*/ true - ); + afterChangeActionKey: "mapChange" + }); - verifyScenarioWhenFileNotPresent( - "when map file is not present", - dtsMapLocation, - verifyMainScenarioAndScriptInfoCollectionWithNoMap - ); + verifyScenarioWhenFileNotPresent({ + scenarioName: "with depedency files map file", + verifier, + withRefs, + disableSourceOfProjectReferenceRedirect, + fileLocation: dtsMapLocation, + fileNotPresentKey: "noMap", + fileCreatedKey: "mapFileCreated", + fileDeletedKey: "mapFileDeleted" + }); - verifyScenarioWhenFileNotPresent( - "when .d.ts file is not present", - dtsLocation, - verifyMainScenarioAndScriptInfoCollectionWithNoDts, - /*noDts*/ true - ); + verifyScenarioWhenFileNotPresent({ + scenarioName: "with depedency .d.ts file", + verifier, + withRefs, + disableSourceOfProjectReferenceRedirect, + fileLocation: dtsLocation, + fileNotPresentKey: "noDts", + fileCreatedKey: "dtsFileCreated", + fileDeletedKey: "dtsFileDeleted", + noDts: true + }); + + if (withRefs && !disableSourceOfProjectReferenceRedirect) { + verifyScenarioWithChanges({ + scenarioName: "when defining project source changes", + verifier, + withRefs, + change: (host, session, verifiers) => { + // Make change, without rebuild of solution + if (contains(openFiles(verifiers), dependencyTs)) { + session.executeCommandSeq({ + command: protocol.CommandTypes.Change, + arguments: { + file: dependencyTs.path, line: 1, offset: 1, endLine: 1, endOffset: 1, insertString: `function fooBar() { } +`} + }); + } + else { + host.writeFile(dependencyTs.path, `function fooBar() { } +${dependencyTs.content}`); + } + }, + afterChangeActionKey: "dependencyChange" + }); + + it("when projects are not built", () => { + const host = createServerHost(files); + const session = createSession(host); + const verifiers = verifier(withRefs); + openFilesForSession([...openFiles(verifiers), randomFile], session); + verifyScenarioAndScriptInfoCollection(session, host, verifiers, "noBuild"); + }); + } } - function verifyScenarios(withRefs: boolean) { - describe(withRefs ? "when main tsconfig has project reference" : "when main tsconfig doesnt have project reference", () => { - const usageVerifier: DocumentPositionMapperVerifier = { - openFile: mainTs, - expectedProjectActualFiles: [mainTs.path, libFile.path, mainConfig.path, dtsPath], - actionGetter: gotoDefintinionFromMainTs, - openFileLastLine: 14 - }; - describe("from project that uses dependency", () => { - const closedInfos = withRefs ? - [dependencyTs.path, dependencyConfig.path, libFile.path, dtsPath, dtsMapLocation] : - [dependencyTs.path, libFile.path, dtsPath, dtsMapLocation]; - verifyDocumentPositionMapperUpdates( - "can go to definition correctly", - [usageVerifier], - closedInfos, - withRefs - ); - }); - - const definingVerifier: DocumentPositionMapperVerifier = { - openFile: dependencyTs, - expectedProjectActualFiles: [dependencyTs.path, libFile.path, dependencyConfig.path], - actionGetter: renameFromDependencyTs, - openFileLastLine: 6, - }; - describe("from defining project", () => { - const closedInfos = [libFile.path, dtsLocation, dtsMapLocation]; - verifyDocumentPositionMapperUpdates( - "rename locations from dependency", - [definingVerifier], - closedInfos, - withRefs - ); - }); - - describe("when opening depedency and usage project", () => { - const closedInfos = withRefs ? - [libFile.path, dtsPath, dtsMapLocation, dependencyConfig.path] : - [libFile.path, dtsPath, dtsMapLocation]; - verifyDocumentPositionMapperUpdates( - "goto Definition in usage and rename locations from defining project", - [usageVerifier, { ...definingVerifier, actionGetter: renameFromDependencyTsWithBothProjectsOpen }], - closedInfos, - withRefs - ); - }); + interface VerifyScenario { + mainScenario: string; + verifier: (withRefs: boolean) => readonly DocumentPositionMapperVerifier[]; + } + function verifyScenario(scenario: VerifyScenario) { + describe("when main tsconfig doesnt have project reference", () => { + verifyScenarioWorker(scenario, /*withRefs*/ false); + }); + describe("when main tsconfig has project reference", () => { + verifyScenarioWorker(scenario, /*withRefs*/ true); + }); + describe("when main tsconfig has but has disableSourceOfProjectReferenceRedirect", () => { + verifyScenarioWorker(scenario, /*withRefs*/ true); }); } - verifyScenarios(/*withRefs*/ false); - verifyScenarios(/*withRefs*/ true); + describe("from project that uses dependency", () => { + verifyScenario({ + mainScenario: "can go to definition correctly", + verifier: withRefs => [ + { + ...goToDefFromMainTsProjectInfoVerifier(withRefs), + main: () => ({ + action: goToDefFromMainTs, + closedInfos: withRefs ? + [dependencyTs.path, dependencyConfig.path, libFile.path] : + [dependencyTs.path, libFile.path, dtsPath, dtsMapLocation], + otherWatchedFiles: [mainConfig.path], + expectsDts: !withRefs, // Dts script info present only if no project reference + expectsMap: !withRefs // Map script info present only if no project reference + }), + change: "main", + dtsChange: "main", + mapChange: ["main", () => ({ + freshDocumentMapper: true + })], + noMap: withRefs ? + "main" : + ["main", main => ({ + action: goToDefFromMainTsWithNoMap, + // Because map is deleted, dts and dependency are released + closedInfos: removePath(main.closedInfos, dtsMapPath, dependencyTsPath), + // Watches deleted file + otherWatchedFiles: main.otherWatchedFiles.concat(dtsMapLocation), + expectsMap: false + })], + mapFileCreated: "main", + mapFileDeleted: withRefs ? + "main" : + ["noMap", noMap => ({ + // The script info for depedency is collected only after file open + closedInfos: noMap.closedInfos.concat(dependencyTs.path) + })], + noDts: withRefs ? + "main" : + ["main", main => ({ + action: goToDefFromMainTsWithNoDts, + // No dts, no map, no dependency + closedInfos: removePath(main.closedInfos, dtsPath, dtsMapPath, dependencyTsPath), + expectsDts: false, + expectsMap: false + })], + dtsFileCreated: "main", + dtsFileDeleted: withRefs ? + "main" : + ["noDts", noDts => ({ + // The script info for map is collected only after file open + closedInfos: noDts.closedInfos.concat(dependencyTs.path, dtsMapLocation), + expectsMap: true + })], + dependencyChange: ["main", () => ({ + action: goToDefFromMainTsWithDependencyChange, + })], + noBuild: "noDts" + } + ] + }); + }); + + describe("from defining project", () => { + verifyScenario({ + mainScenario: "rename locations from dependency", + verifier: () => [ + { + ...renameFromDependencyTsProjectInfoVerifier(), + main: () => ({ + action: renameFromDependencyTs, + closedInfos: [libFile.path, dtsLocation, dtsMapLocation], + otherWatchedFiles: [dependencyConfig.path], + expectsDts: true, + expectsMap: true + }), + change: "main", + dtsChange: "main", + mapChange: ["main", () => ({ + freshDocumentMapper: true + })], + noMap: ["main", main => ({ + // No map + closedInfos: removePath(main.closedInfos, dtsMapPath), + // watch map + otherWatchedFiles: [...main.otherWatchedFiles, dtsMapLocation], + expectsMap: false + })], + mapFileCreated: "main", + mapFileDeleted: "noMap", + noDts: ["main", main => ({ + // no dts or map since dts itself doesnt exist + closedInfos: removePath(main.closedInfos, dtsMapPath, dtsPath), + // watch deleted file + otherWatchedFiles: [...main.otherWatchedFiles, dtsLocation], + expectsDts: false, + expectsMap: false + })], + dtsFileCreated: "main", + dtsFileDeleted: ["noDts", noDts => ({ + // Map is collected after file open + closedInfos: noDts.closedInfos.concat(dtsMapLocation), + expectsMap: true + })], + dependencyChange: ["main", () => ({ + action: renameFromDependencyTsWithDependencyChange + })], + noBuild: "noDts" + } + ] + }); + }); + + describe("when opening depedency and usage project", () => { + verifyScenario({ + mainScenario: "goto Definition in usage and rename locations from defining project", + verifier: withRefs => [ + { + ...goToDefFromMainTsProjectInfoVerifier(withRefs), + main: () => ({ + action: goToDefFromMainTs, + // DependencyTs is open, so omit it from closed infos + closedInfos: withRefs ? + [dependencyConfig.path, libFile.path] : + [libFile.path, dtsPath, dtsMapLocation], + otherWatchedFiles: withRefs ? + [mainConfig.path] : // Its in closed info + [mainConfig.path, dependencyConfig.path], + expectsDts: !withRefs, // Dts script info present only if no project reference + expectsMap: !withRefs // Map script info present only if no project reference + }), + change: withRefs ? + ["main", main => ({ + // Because before this rename is done the closed info remains same as rename's main operation + closedInfos: main.closedInfos.concat(dtsLocation, dtsMapLocation), + expectsDts: true, + expectsMap: true + })] : + "main", + dtsChange: "change", + mapChange: "change", + noMap: withRefs ? + "main" : + ["main", main => ({ + action: goToDefFromMainTsWithNoMap, + closedInfos: removePath(main.closedInfos, dtsMapPath), + otherWatchedFiles: main.otherWatchedFiles.concat(dtsMapLocation), + expectsMap: false + })], + mapFileCreated: withRefs ? + ["main", main => ({ + // Because before this rename is done the closed info remains same as rename's main + closedInfos: main.closedInfos.concat(dtsLocation), + expectsDts: true, + // This operation doesnt need map so the map info path in dts is not refreshed + skipDtsMapCheck: withRefs + })] : + "main", + mapFileDeleted: withRefs ? + ["noMap", noMap => ({ + // Because before this rename is done the closed info remains same as rename's noMap operation + closedInfos: noMap.closedInfos.concat(dtsLocation), + expectsDts: true, + // This operation doesnt need map so the map info path in dts is not refreshed + skipDtsMapCheck: true + })] : + "noMap", + noDts: withRefs ? + "main" : + ["main", main => ({ + action: goToDefFromMainTsWithNoDts, + closedInfos: removePath(main.closedInfos, dtsMapPath, dtsPath), + expectsDts: false, + expectsMap: false + })], + dtsFileCreated: withRefs ? + ["main", main => ({ + // Since the project for dependency is not updated, the watcher from rename for dts still there + otherWatchedFiles: main.otherWatchedFiles.concat(dtsLocation) + })] : + "main", + dtsFileDeleted: ["noDts", noDts => ({ + // Map collection after file open + closedInfos: noDts.closedInfos.concat(dtsMapLocation), + expectsMap: true + })], + dependencyChange: ["change", () => ({ + action: goToDefFromMainTsWithDependencyChange, + })], + noBuild: "noDts" + }, + { + ...renameFromDependencyTsProjectInfoVerifier(), + main: () => ({ + action: renameFromDependencyTsWithBothProjectsOpen, + // DependencyTs is open, so omit it from closed infos + closedInfos: withRefs ? + [dependencyConfig.path, libFile.path, dtsLocation, dtsMapLocation] : + [libFile.path, dtsPath, dtsMapLocation], + otherWatchedFiles: withRefs ? + [mainConfig.path] : // Its in closed info + [mainConfig.path, dependencyConfig.path], + expectsDts: true, + expectsMap: true, + freshMapInfo: withRefs + }), + change: ["main", () => ({ + freshMapInfo: false + })], + dtsChange: "change", + mapChange: ["main", () => ({ + freshMapInfo: false, + freshDocumentMapper: withRefs + })], + noMap: ["main", main => ({ + action: withRefs ? + renameFromDependencyTsWithBothProjectsOpen : + renameFromDependencyTs, + closedInfos: removePath(main.closedInfos, dtsMapPath), + otherWatchedFiles: main.otherWatchedFiles.concat(dtsMapLocation), + expectsMap: false, + freshDocumentMapper: withRefs + })], + mapFileCreated: "main", + mapFileDeleted: "noMap", + noDts: ["change", change => ({ + action: withRefs ? + renameFromDependencyTsWithBothProjectsOpen : + renameFromDependencyTs, + closedInfos: removePath(change.closedInfos, dtsPath, dtsMapPath), + otherWatchedFiles: change.otherWatchedFiles.concat(dtsLocation), + expectsDts: false, + expectsMap: false + })], + dtsFileCreated: "main", + dtsFileDeleted: ["noDts", noDts => ({ + // Map collection after file open + closedInfos: noDts.closedInfos.concat(dtsMapLocation) , + expectsMap: true + })], + dependencyChange: ["change", () => ({ + action: renameFromDependencyTsWithBothProjectsOpenWithDependencyChange + })], + noBuild: "noDts" + } + ] + }); + }); }); it("reusing d.ts files from composite and non composite projects", () => { @@ -774,7 +1246,7 @@ fn5(); service.openClientFile(cTs.path); service.checkNumberOfProjects({ configuredProjects: 2 }); const projectC = service.configuredProjects.get(configC.path)!; - checkProjectActualFiles(projectC, [cTs.path, bDts.path, libFile.path, configC.path]); + checkProjectActualFiles(projectC, [cTs.path, bTs.path, libFile.path, configC.path]); // Now new project for project A tries to reuse b but there is no filesByName mapping for b's source location host.writeFile(a2Ts.path, `${a2Ts.content}export const y = 30;`); diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 79450ca83c9..390ba29da27 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -73,7 +73,7 @@ declare namespace ts { end: number; } export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; - export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; + export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; export enum SyntaxKind { Unknown = 0, @@ -198,206 +198,207 @@ declare namespace ts { YieldKeyword = 118, AbstractKeyword = 119, AsKeyword = 120, - AnyKeyword = 121, - AsyncKeyword = 122, - AwaitKeyword = 123, - BooleanKeyword = 124, - ConstructorKeyword = 125, - DeclareKeyword = 126, - GetKeyword = 127, - InferKeyword = 128, - IsKeyword = 129, - KeyOfKeyword = 130, - ModuleKeyword = 131, - NamespaceKeyword = 132, - NeverKeyword = 133, - ReadonlyKeyword = 134, - RequireKeyword = 135, - NumberKeyword = 136, - ObjectKeyword = 137, - SetKeyword = 138, - StringKeyword = 139, - SymbolKeyword = 140, - TypeKeyword = 141, - UndefinedKeyword = 142, - UniqueKeyword = 143, - UnknownKeyword = 144, - FromKeyword = 145, - GlobalKeyword = 146, - BigIntKeyword = 147, - OfKeyword = 148, - QualifiedName = 149, - ComputedPropertyName = 150, - TypeParameter = 151, - Parameter = 152, - Decorator = 153, - PropertySignature = 154, - PropertyDeclaration = 155, - MethodSignature = 156, - MethodDeclaration = 157, - Constructor = 158, - GetAccessor = 159, - SetAccessor = 160, - CallSignature = 161, - ConstructSignature = 162, - IndexSignature = 163, - TypePredicate = 164, - TypeReference = 165, - FunctionType = 166, - ConstructorType = 167, - TypeQuery = 168, - TypeLiteral = 169, - ArrayType = 170, - TupleType = 171, - OptionalType = 172, - RestType = 173, - UnionType = 174, - IntersectionType = 175, - ConditionalType = 176, - InferType = 177, - ParenthesizedType = 178, - ThisType = 179, - TypeOperator = 180, - IndexedAccessType = 181, - MappedType = 182, - LiteralType = 183, - ImportType = 184, - ObjectBindingPattern = 185, - ArrayBindingPattern = 186, - BindingElement = 187, - ArrayLiteralExpression = 188, - ObjectLiteralExpression = 189, - PropertyAccessExpression = 190, - ElementAccessExpression = 191, - CallExpression = 192, - NewExpression = 193, - TaggedTemplateExpression = 194, - TypeAssertionExpression = 195, - ParenthesizedExpression = 196, - FunctionExpression = 197, - ArrowFunction = 198, - DeleteExpression = 199, - TypeOfExpression = 200, - VoidExpression = 201, - AwaitExpression = 202, - PrefixUnaryExpression = 203, - PostfixUnaryExpression = 204, - BinaryExpression = 205, - ConditionalExpression = 206, - TemplateExpression = 207, - YieldExpression = 208, - SpreadElement = 209, - ClassExpression = 210, - OmittedExpression = 211, - ExpressionWithTypeArguments = 212, - AsExpression = 213, - NonNullExpression = 214, - MetaProperty = 215, - SyntheticExpression = 216, - TemplateSpan = 217, - SemicolonClassElement = 218, - Block = 219, - VariableStatement = 220, + AssertsKeyword = 121, + AnyKeyword = 122, + AsyncKeyword = 123, + AwaitKeyword = 124, + BooleanKeyword = 125, + ConstructorKeyword = 126, + DeclareKeyword = 127, + GetKeyword = 128, + InferKeyword = 129, + IsKeyword = 130, + KeyOfKeyword = 131, + ModuleKeyword = 132, + NamespaceKeyword = 133, + NeverKeyword = 134, + ReadonlyKeyword = 135, + RequireKeyword = 136, + NumberKeyword = 137, + ObjectKeyword = 138, + SetKeyword = 139, + StringKeyword = 140, + SymbolKeyword = 141, + TypeKeyword = 142, + UndefinedKeyword = 143, + UniqueKeyword = 144, + UnknownKeyword = 145, + FromKeyword = 146, + GlobalKeyword = 147, + BigIntKeyword = 148, + OfKeyword = 149, + QualifiedName = 150, + ComputedPropertyName = 151, + TypeParameter = 152, + Parameter = 153, + Decorator = 154, + PropertySignature = 155, + PropertyDeclaration = 156, + MethodSignature = 157, + MethodDeclaration = 158, + Constructor = 159, + GetAccessor = 160, + SetAccessor = 161, + CallSignature = 162, + ConstructSignature = 163, + IndexSignature = 164, + TypePredicate = 165, + TypeReference = 166, + FunctionType = 167, + ConstructorType = 168, + TypeQuery = 169, + TypeLiteral = 170, + ArrayType = 171, + TupleType = 172, + OptionalType = 173, + RestType = 174, + UnionType = 175, + IntersectionType = 176, + ConditionalType = 177, + InferType = 178, + ParenthesizedType = 179, + ThisType = 180, + TypeOperator = 181, + IndexedAccessType = 182, + MappedType = 183, + LiteralType = 184, + ImportType = 185, + ObjectBindingPattern = 186, + ArrayBindingPattern = 187, + BindingElement = 188, + ArrayLiteralExpression = 189, + ObjectLiteralExpression = 190, + PropertyAccessExpression = 191, + ElementAccessExpression = 192, + CallExpression = 193, + NewExpression = 194, + TaggedTemplateExpression = 195, + TypeAssertionExpression = 196, + ParenthesizedExpression = 197, + FunctionExpression = 198, + ArrowFunction = 199, + DeleteExpression = 200, + TypeOfExpression = 201, + VoidExpression = 202, + AwaitExpression = 203, + PrefixUnaryExpression = 204, + PostfixUnaryExpression = 205, + BinaryExpression = 206, + ConditionalExpression = 207, + TemplateExpression = 208, + YieldExpression = 209, + SpreadElement = 210, + ClassExpression = 211, + OmittedExpression = 212, + ExpressionWithTypeArguments = 213, + AsExpression = 214, + NonNullExpression = 215, + MetaProperty = 216, + SyntheticExpression = 217, + TemplateSpan = 218, + SemicolonClassElement = 219, + Block = 220, EmptyStatement = 221, - ExpressionStatement = 222, - IfStatement = 223, - DoStatement = 224, - WhileStatement = 225, - ForStatement = 226, - ForInStatement = 227, - ForOfStatement = 228, - ContinueStatement = 229, - BreakStatement = 230, - ReturnStatement = 231, - WithStatement = 232, - SwitchStatement = 233, - LabeledStatement = 234, - ThrowStatement = 235, - TryStatement = 236, - DebuggerStatement = 237, - VariableDeclaration = 238, - VariableDeclarationList = 239, - FunctionDeclaration = 240, - ClassDeclaration = 241, - InterfaceDeclaration = 242, - TypeAliasDeclaration = 243, - EnumDeclaration = 244, - ModuleDeclaration = 245, - ModuleBlock = 246, - CaseBlock = 247, - NamespaceExportDeclaration = 248, - ImportEqualsDeclaration = 249, - ImportDeclaration = 250, - ImportClause = 251, - NamespaceImport = 252, - NamedImports = 253, - ImportSpecifier = 254, - ExportAssignment = 255, - ExportDeclaration = 256, - NamedExports = 257, - ExportSpecifier = 258, - MissingDeclaration = 259, - ExternalModuleReference = 260, - JsxElement = 261, - JsxSelfClosingElement = 262, - JsxOpeningElement = 263, - JsxClosingElement = 264, - JsxFragment = 265, - JsxOpeningFragment = 266, - JsxClosingFragment = 267, - JsxAttribute = 268, - JsxAttributes = 269, - JsxSpreadAttribute = 270, - JsxExpression = 271, - CaseClause = 272, - DefaultClause = 273, - HeritageClause = 274, - CatchClause = 275, - PropertyAssignment = 276, - ShorthandPropertyAssignment = 277, - SpreadAssignment = 278, - EnumMember = 279, - UnparsedPrologue = 280, - UnparsedPrepend = 281, - UnparsedText = 282, - UnparsedInternalText = 283, - UnparsedSyntheticReference = 284, - SourceFile = 285, - Bundle = 286, - UnparsedSource = 287, - InputFiles = 288, - JSDocTypeExpression = 289, - JSDocAllType = 290, - JSDocUnknownType = 291, - JSDocNullableType = 292, - JSDocNonNullableType = 293, - JSDocOptionalType = 294, - JSDocFunctionType = 295, - JSDocVariadicType = 296, - JSDocNamepathType = 297, - JSDocComment = 298, - JSDocTypeLiteral = 299, - JSDocSignature = 300, - JSDocTag = 301, - JSDocAugmentsTag = 302, - JSDocAuthorTag = 303, - JSDocClassTag = 304, - JSDocCallbackTag = 305, - JSDocEnumTag = 306, - JSDocParameterTag = 307, - JSDocReturnTag = 308, - JSDocThisTag = 309, - JSDocTypeTag = 310, - JSDocTemplateTag = 311, - JSDocTypedefTag = 312, - JSDocPropertyTag = 313, - SyntaxList = 314, - NotEmittedStatement = 315, - PartiallyEmittedExpression = 316, - CommaListExpression = 317, - MergeDeclarationMarker = 318, - EndOfDeclarationMarker = 319, - Count = 320, + VariableStatement = 222, + ExpressionStatement = 223, + IfStatement = 224, + DoStatement = 225, + WhileStatement = 226, + ForStatement = 227, + ForInStatement = 228, + ForOfStatement = 229, + ContinueStatement = 230, + BreakStatement = 231, + ReturnStatement = 232, + WithStatement = 233, + SwitchStatement = 234, + LabeledStatement = 235, + ThrowStatement = 236, + TryStatement = 237, + DebuggerStatement = 238, + VariableDeclaration = 239, + VariableDeclarationList = 240, + FunctionDeclaration = 241, + ClassDeclaration = 242, + InterfaceDeclaration = 243, + TypeAliasDeclaration = 244, + EnumDeclaration = 245, + ModuleDeclaration = 246, + ModuleBlock = 247, + CaseBlock = 248, + NamespaceExportDeclaration = 249, + ImportEqualsDeclaration = 250, + ImportDeclaration = 251, + ImportClause = 252, + NamespaceImport = 253, + NamedImports = 254, + ImportSpecifier = 255, + ExportAssignment = 256, + ExportDeclaration = 257, + NamedExports = 258, + ExportSpecifier = 259, + MissingDeclaration = 260, + ExternalModuleReference = 261, + JsxElement = 262, + JsxSelfClosingElement = 263, + JsxOpeningElement = 264, + JsxClosingElement = 265, + JsxFragment = 266, + JsxOpeningFragment = 267, + JsxClosingFragment = 268, + JsxAttribute = 269, + JsxAttributes = 270, + JsxSpreadAttribute = 271, + JsxExpression = 272, + CaseClause = 273, + DefaultClause = 274, + HeritageClause = 275, + CatchClause = 276, + PropertyAssignment = 277, + ShorthandPropertyAssignment = 278, + SpreadAssignment = 279, + EnumMember = 280, + UnparsedPrologue = 281, + UnparsedPrepend = 282, + UnparsedText = 283, + UnparsedInternalText = 284, + UnparsedSyntheticReference = 285, + SourceFile = 286, + Bundle = 287, + UnparsedSource = 288, + InputFiles = 289, + JSDocTypeExpression = 290, + JSDocAllType = 291, + JSDocUnknownType = 292, + JSDocNullableType = 293, + JSDocNonNullableType = 294, + JSDocOptionalType = 295, + JSDocFunctionType = 296, + JSDocVariadicType = 297, + JSDocNamepathType = 298, + JSDocComment = 299, + JSDocTypeLiteral = 300, + JSDocSignature = 301, + JSDocTag = 302, + JSDocAugmentsTag = 303, + JSDocAuthorTag = 304, + JSDocClassTag = 305, + JSDocCallbackTag = 306, + JSDocEnumTag = 307, + JSDocParameterTag = 308, + JSDocReturnTag = 309, + JSDocThisTag = 310, + JSDocTypeTag = 311, + JSDocTemplateTag = 312, + JSDocTypedefTag = 313, + JSDocPropertyTag = 314, + SyntaxList = 315, + NotEmittedStatement = 316, + PartiallyEmittedExpression = 317, + CommaListExpression = 318, + MergeDeclarationMarker = 319, + EndOfDeclarationMarker = 320, + Count = 321, FirstAssignment = 60, LastAssignment = 72, FirstCompoundAssignment = 61, @@ -405,15 +406,15 @@ declare namespace ts { FirstReservedWord = 74, LastReservedWord = 109, FirstKeyword = 74, - LastKeyword = 148, + LastKeyword = 149, FirstFutureReservedWord = 110, LastFutureReservedWord = 118, - FirstTypeNode = 164, - LastTypeNode = 184, + FirstTypeNode = 165, + LastTypeNode = 185, FirstPunctuation = 18, LastPunctuation = 72, FirstToken = 0, - LastToken = 148, + LastToken = 149, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -422,11 +423,13 @@ declare namespace ts { LastTemplateToken = 17, FirstBinaryOperator = 28, LastBinaryOperator = 72, - FirstNode = 149, - FirstJSDocNode = 289, - LastJSDocNode = 313, - FirstJSDocTagNode = 301, - LastJSDocTagNode = 313, + FirstStatement = 222, + LastStatement = 238, + FirstNode = 150, + FirstJSDocNode = 290, + LastJSDocNode = 314, + FirstJSDocTagNode = 302, + LastJSDocTagNode = 314, } export enum NodeFlags { None = 0, @@ -517,6 +520,7 @@ declare namespace ts { export type AwaitKeywordToken = Token; export type PlusToken = Token; export type MinusToken = Token; + export type AssertsToken = Token; export type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; export type ModifiersArray = NodeArray; export interface Identifier extends PrimaryExpression, Declaration { @@ -770,8 +774,9 @@ declare namespace ts { export interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; parent: SignatureDeclaration | JSDocTypeExpression; + assertsModifier?: AssertsToken; parameterName: Identifier | ThisTypeNode; - type: TypeNode; + type?: TypeNode; } export interface TypeQueryNode extends TypeNode { kind: SyntaxKind.TypeQuery; @@ -1669,13 +1674,19 @@ declare namespace ts { FalseCondition = 64, SwitchClause = 128, ArrayMutation = 256, - Referenced = 512, - Shared = 1024, - PreFinally = 2048, - AfterFinally = 4096, + Call = 512, + Referenced = 1024, + Shared = 2048, + PreFinally = 4096, + AfterFinally = 8192, Label = 12, Condition = 96 } + export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCall | FlowCondition | FlowSwitchClause | FlowArrayMutation; + export interface FlowNodeBase { + flags: FlowFlags; + id?: number; + } export interface FlowLock { locked?: boolean; } @@ -1686,13 +1697,8 @@ declare namespace ts { antecedent: FlowNode; lock: FlowLock; } - export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation; - export interface FlowNodeBase { - flags: FlowFlags; - id?: number; - } export interface FlowStart extends FlowNodeBase { - container?: FunctionExpression | ArrowFunction | MethodDeclaration; + node?: FunctionExpression | ArrowFunction | MethodDeclaration; } export interface FlowLabel extends FlowNodeBase { antecedents: FlowNode[] | undefined; @@ -1701,8 +1707,12 @@ declare namespace ts { node: Expression | VariableDeclaration | BindingElement; antecedent: FlowNode; } + export interface FlowCall extends FlowNodeBase { + node: CallExpression; + antecedent: FlowNode; + } export interface FlowCondition extends FlowNodeBase { - expression: Expression; + node: Expression; antecedent: FlowNode; } export interface FlowSwitchClause extends FlowNodeBase { @@ -1957,6 +1967,7 @@ declare namespace ts { getReturnTypeOfSignature(signature: Signature): Type; getNullableType(type: Type, flags: TypeFlags): Type; getNonNullableType(type: Type): Type; + getTypeArguments(type: TypeReference): readonly Type[]; /** Note that the resulting nodes cannot be checked. */ typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode | undefined; /** Note that the resulting nodes cannot be checked. */ @@ -2098,21 +2109,39 @@ declare namespace ts { } export enum TypePredicateKind { This = 0, - Identifier = 1 + Identifier = 1, + AssertsThis = 2, + AssertsIdentifier = 3 } export interface TypePredicateBase { kind: TypePredicateKind; - type: Type; + type: Type | undefined; } export interface ThisTypePredicate extends TypePredicateBase { kind: TypePredicateKind.This; + parameterName: undefined; + parameterIndex: undefined; + type: Type; } export interface IdentifierTypePredicate extends TypePredicateBase { kind: TypePredicateKind.Identifier; parameterName: string; parameterIndex: number; + type: Type; } - export type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; + export interface AssertsThisTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.AssertsThis; + parameterName: undefined; + parameterIndex: undefined; + type: Type | undefined; + } + export interface AssertsIdentifierTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.AssertsIdentifier; + parameterName: string; + parameterIndex: number; + type: Type | undefined; + } + export type TypePredicate = ThisTypePredicate | IdentifierTypePredicate | AssertsThisTypePredicate | AssertsIdentifierTypePredicate; export enum SymbolFlags { None = 0, FunctionScopedVariable = 1, @@ -2340,7 +2369,7 @@ declare namespace ts { localTypeParameters: TypeParameter[] | undefined; thisType: TypeParameter | undefined; } - export type BaseType = ObjectType | IntersectionType; + export type BaseType = ObjectType | IntersectionType | TypeVariable; export interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; @@ -2360,7 +2389,9 @@ declare namespace ts { */ export interface TypeReference extends ObjectType { target: GenericType; - typeArguments?: readonly Type[]; + node?: TypeReferenceNode | ArrayTypeNode | TupleTypeNode; + } + export interface DeferredTypeReference extends TypeReference { } export interface GenericType extends InterfaceType, TypeReference { } @@ -2539,6 +2570,7 @@ declare namespace ts { emitDeclarationOnly?: boolean; declarationDir?: string; disableSizeLimit?: boolean; + disableSourceOfProjectReferenceRedirect?: boolean; downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; @@ -3845,7 +3877,9 @@ declare namespace ts { function updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode; function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode; + function createTypePredicateNodeWithModifier(assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode | string, type: TypeNode | undefined): TypePredicateNode; function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode; + function updateTypePredicateNodeWithModifier(node: TypePredicateNode, assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode, type: TypeNode | undefined): TypePredicateNode; function createTypeReferenceNode(typeName: string | EntityName, typeArguments: readonly TypeNode[] | undefined): TypeReferenceNode; function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray | undefined): TypeReferenceNode; function createFunctionTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode; @@ -8499,7 +8533,6 @@ declare namespace ts.server { getGlobalProjectErrors(): readonly Diagnostic[]; getAllProjectErrors(): readonly Diagnostic[]; getLanguageService(ensureSynchronized?: boolean): LanguageService; - private shouldEmitFile; getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[]; /** * Returns true if emit was conducted @@ -8580,11 +8613,25 @@ declare namespace ts.server { private typeAcquisition; private directoriesWatchedForWildcards; readonly canonicalConfigFilePath: NormalizedPath; + private projectReferenceCallbacks; + private mapOfDeclarationDirectories; /** Ref count to the project when opened from external project */ private externalProjectRefCount; private projectErrors; private projectReferences; protected isInitialLoadPending: () => boolean; + /** + * This implementation of fileExists checks if the file being requested is + * .d.ts file for the referenced Project. + * If it is it returns true irrespective of whether that file exists on host + */ + fileExists(file: string): boolean; + /** + * This implementation of directoryExists checks if the directory being requested is + * directory of .d.ts file for the referenced Project. + * If it is it returns true irrespective of whether that directory exists on host + */ + directoryExists(path: string): boolean; /** * If the project has reload from disk pending, it reloads (and then updates graph as part of that) instead of just updating the graph * @returns: true if set of files in the project stays the same and false - otherwise. diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index f0ae718d570..594a83ce0b5 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -73,7 +73,7 @@ declare namespace ts { end: number; } export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; - export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; + export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; export enum SyntaxKind { Unknown = 0, @@ -198,206 +198,207 @@ declare namespace ts { YieldKeyword = 118, AbstractKeyword = 119, AsKeyword = 120, - AnyKeyword = 121, - AsyncKeyword = 122, - AwaitKeyword = 123, - BooleanKeyword = 124, - ConstructorKeyword = 125, - DeclareKeyword = 126, - GetKeyword = 127, - InferKeyword = 128, - IsKeyword = 129, - KeyOfKeyword = 130, - ModuleKeyword = 131, - NamespaceKeyword = 132, - NeverKeyword = 133, - ReadonlyKeyword = 134, - RequireKeyword = 135, - NumberKeyword = 136, - ObjectKeyword = 137, - SetKeyword = 138, - StringKeyword = 139, - SymbolKeyword = 140, - TypeKeyword = 141, - UndefinedKeyword = 142, - UniqueKeyword = 143, - UnknownKeyword = 144, - FromKeyword = 145, - GlobalKeyword = 146, - BigIntKeyword = 147, - OfKeyword = 148, - QualifiedName = 149, - ComputedPropertyName = 150, - TypeParameter = 151, - Parameter = 152, - Decorator = 153, - PropertySignature = 154, - PropertyDeclaration = 155, - MethodSignature = 156, - MethodDeclaration = 157, - Constructor = 158, - GetAccessor = 159, - SetAccessor = 160, - CallSignature = 161, - ConstructSignature = 162, - IndexSignature = 163, - TypePredicate = 164, - TypeReference = 165, - FunctionType = 166, - ConstructorType = 167, - TypeQuery = 168, - TypeLiteral = 169, - ArrayType = 170, - TupleType = 171, - OptionalType = 172, - RestType = 173, - UnionType = 174, - IntersectionType = 175, - ConditionalType = 176, - InferType = 177, - ParenthesizedType = 178, - ThisType = 179, - TypeOperator = 180, - IndexedAccessType = 181, - MappedType = 182, - LiteralType = 183, - ImportType = 184, - ObjectBindingPattern = 185, - ArrayBindingPattern = 186, - BindingElement = 187, - ArrayLiteralExpression = 188, - ObjectLiteralExpression = 189, - PropertyAccessExpression = 190, - ElementAccessExpression = 191, - CallExpression = 192, - NewExpression = 193, - TaggedTemplateExpression = 194, - TypeAssertionExpression = 195, - ParenthesizedExpression = 196, - FunctionExpression = 197, - ArrowFunction = 198, - DeleteExpression = 199, - TypeOfExpression = 200, - VoidExpression = 201, - AwaitExpression = 202, - PrefixUnaryExpression = 203, - PostfixUnaryExpression = 204, - BinaryExpression = 205, - ConditionalExpression = 206, - TemplateExpression = 207, - YieldExpression = 208, - SpreadElement = 209, - ClassExpression = 210, - OmittedExpression = 211, - ExpressionWithTypeArguments = 212, - AsExpression = 213, - NonNullExpression = 214, - MetaProperty = 215, - SyntheticExpression = 216, - TemplateSpan = 217, - SemicolonClassElement = 218, - Block = 219, - VariableStatement = 220, + AssertsKeyword = 121, + AnyKeyword = 122, + AsyncKeyword = 123, + AwaitKeyword = 124, + BooleanKeyword = 125, + ConstructorKeyword = 126, + DeclareKeyword = 127, + GetKeyword = 128, + InferKeyword = 129, + IsKeyword = 130, + KeyOfKeyword = 131, + ModuleKeyword = 132, + NamespaceKeyword = 133, + NeverKeyword = 134, + ReadonlyKeyword = 135, + RequireKeyword = 136, + NumberKeyword = 137, + ObjectKeyword = 138, + SetKeyword = 139, + StringKeyword = 140, + SymbolKeyword = 141, + TypeKeyword = 142, + UndefinedKeyword = 143, + UniqueKeyword = 144, + UnknownKeyword = 145, + FromKeyword = 146, + GlobalKeyword = 147, + BigIntKeyword = 148, + OfKeyword = 149, + QualifiedName = 150, + ComputedPropertyName = 151, + TypeParameter = 152, + Parameter = 153, + Decorator = 154, + PropertySignature = 155, + PropertyDeclaration = 156, + MethodSignature = 157, + MethodDeclaration = 158, + Constructor = 159, + GetAccessor = 160, + SetAccessor = 161, + CallSignature = 162, + ConstructSignature = 163, + IndexSignature = 164, + TypePredicate = 165, + TypeReference = 166, + FunctionType = 167, + ConstructorType = 168, + TypeQuery = 169, + TypeLiteral = 170, + ArrayType = 171, + TupleType = 172, + OptionalType = 173, + RestType = 174, + UnionType = 175, + IntersectionType = 176, + ConditionalType = 177, + InferType = 178, + ParenthesizedType = 179, + ThisType = 180, + TypeOperator = 181, + IndexedAccessType = 182, + MappedType = 183, + LiteralType = 184, + ImportType = 185, + ObjectBindingPattern = 186, + ArrayBindingPattern = 187, + BindingElement = 188, + ArrayLiteralExpression = 189, + ObjectLiteralExpression = 190, + PropertyAccessExpression = 191, + ElementAccessExpression = 192, + CallExpression = 193, + NewExpression = 194, + TaggedTemplateExpression = 195, + TypeAssertionExpression = 196, + ParenthesizedExpression = 197, + FunctionExpression = 198, + ArrowFunction = 199, + DeleteExpression = 200, + TypeOfExpression = 201, + VoidExpression = 202, + AwaitExpression = 203, + PrefixUnaryExpression = 204, + PostfixUnaryExpression = 205, + BinaryExpression = 206, + ConditionalExpression = 207, + TemplateExpression = 208, + YieldExpression = 209, + SpreadElement = 210, + ClassExpression = 211, + OmittedExpression = 212, + ExpressionWithTypeArguments = 213, + AsExpression = 214, + NonNullExpression = 215, + MetaProperty = 216, + SyntheticExpression = 217, + TemplateSpan = 218, + SemicolonClassElement = 219, + Block = 220, EmptyStatement = 221, - ExpressionStatement = 222, - IfStatement = 223, - DoStatement = 224, - WhileStatement = 225, - ForStatement = 226, - ForInStatement = 227, - ForOfStatement = 228, - ContinueStatement = 229, - BreakStatement = 230, - ReturnStatement = 231, - WithStatement = 232, - SwitchStatement = 233, - LabeledStatement = 234, - ThrowStatement = 235, - TryStatement = 236, - DebuggerStatement = 237, - VariableDeclaration = 238, - VariableDeclarationList = 239, - FunctionDeclaration = 240, - ClassDeclaration = 241, - InterfaceDeclaration = 242, - TypeAliasDeclaration = 243, - EnumDeclaration = 244, - ModuleDeclaration = 245, - ModuleBlock = 246, - CaseBlock = 247, - NamespaceExportDeclaration = 248, - ImportEqualsDeclaration = 249, - ImportDeclaration = 250, - ImportClause = 251, - NamespaceImport = 252, - NamedImports = 253, - ImportSpecifier = 254, - ExportAssignment = 255, - ExportDeclaration = 256, - NamedExports = 257, - ExportSpecifier = 258, - MissingDeclaration = 259, - ExternalModuleReference = 260, - JsxElement = 261, - JsxSelfClosingElement = 262, - JsxOpeningElement = 263, - JsxClosingElement = 264, - JsxFragment = 265, - JsxOpeningFragment = 266, - JsxClosingFragment = 267, - JsxAttribute = 268, - JsxAttributes = 269, - JsxSpreadAttribute = 270, - JsxExpression = 271, - CaseClause = 272, - DefaultClause = 273, - HeritageClause = 274, - CatchClause = 275, - PropertyAssignment = 276, - ShorthandPropertyAssignment = 277, - SpreadAssignment = 278, - EnumMember = 279, - UnparsedPrologue = 280, - UnparsedPrepend = 281, - UnparsedText = 282, - UnparsedInternalText = 283, - UnparsedSyntheticReference = 284, - SourceFile = 285, - Bundle = 286, - UnparsedSource = 287, - InputFiles = 288, - JSDocTypeExpression = 289, - JSDocAllType = 290, - JSDocUnknownType = 291, - JSDocNullableType = 292, - JSDocNonNullableType = 293, - JSDocOptionalType = 294, - JSDocFunctionType = 295, - JSDocVariadicType = 296, - JSDocNamepathType = 297, - JSDocComment = 298, - JSDocTypeLiteral = 299, - JSDocSignature = 300, - JSDocTag = 301, - JSDocAugmentsTag = 302, - JSDocAuthorTag = 303, - JSDocClassTag = 304, - JSDocCallbackTag = 305, - JSDocEnumTag = 306, - JSDocParameterTag = 307, - JSDocReturnTag = 308, - JSDocThisTag = 309, - JSDocTypeTag = 310, - JSDocTemplateTag = 311, - JSDocTypedefTag = 312, - JSDocPropertyTag = 313, - SyntaxList = 314, - NotEmittedStatement = 315, - PartiallyEmittedExpression = 316, - CommaListExpression = 317, - MergeDeclarationMarker = 318, - EndOfDeclarationMarker = 319, - Count = 320, + VariableStatement = 222, + ExpressionStatement = 223, + IfStatement = 224, + DoStatement = 225, + WhileStatement = 226, + ForStatement = 227, + ForInStatement = 228, + ForOfStatement = 229, + ContinueStatement = 230, + BreakStatement = 231, + ReturnStatement = 232, + WithStatement = 233, + SwitchStatement = 234, + LabeledStatement = 235, + ThrowStatement = 236, + TryStatement = 237, + DebuggerStatement = 238, + VariableDeclaration = 239, + VariableDeclarationList = 240, + FunctionDeclaration = 241, + ClassDeclaration = 242, + InterfaceDeclaration = 243, + TypeAliasDeclaration = 244, + EnumDeclaration = 245, + ModuleDeclaration = 246, + ModuleBlock = 247, + CaseBlock = 248, + NamespaceExportDeclaration = 249, + ImportEqualsDeclaration = 250, + ImportDeclaration = 251, + ImportClause = 252, + NamespaceImport = 253, + NamedImports = 254, + ImportSpecifier = 255, + ExportAssignment = 256, + ExportDeclaration = 257, + NamedExports = 258, + ExportSpecifier = 259, + MissingDeclaration = 260, + ExternalModuleReference = 261, + JsxElement = 262, + JsxSelfClosingElement = 263, + JsxOpeningElement = 264, + JsxClosingElement = 265, + JsxFragment = 266, + JsxOpeningFragment = 267, + JsxClosingFragment = 268, + JsxAttribute = 269, + JsxAttributes = 270, + JsxSpreadAttribute = 271, + JsxExpression = 272, + CaseClause = 273, + DefaultClause = 274, + HeritageClause = 275, + CatchClause = 276, + PropertyAssignment = 277, + ShorthandPropertyAssignment = 278, + SpreadAssignment = 279, + EnumMember = 280, + UnparsedPrologue = 281, + UnparsedPrepend = 282, + UnparsedText = 283, + UnparsedInternalText = 284, + UnparsedSyntheticReference = 285, + SourceFile = 286, + Bundle = 287, + UnparsedSource = 288, + InputFiles = 289, + JSDocTypeExpression = 290, + JSDocAllType = 291, + JSDocUnknownType = 292, + JSDocNullableType = 293, + JSDocNonNullableType = 294, + JSDocOptionalType = 295, + JSDocFunctionType = 296, + JSDocVariadicType = 297, + JSDocNamepathType = 298, + JSDocComment = 299, + JSDocTypeLiteral = 300, + JSDocSignature = 301, + JSDocTag = 302, + JSDocAugmentsTag = 303, + JSDocAuthorTag = 304, + JSDocClassTag = 305, + JSDocCallbackTag = 306, + JSDocEnumTag = 307, + JSDocParameterTag = 308, + JSDocReturnTag = 309, + JSDocThisTag = 310, + JSDocTypeTag = 311, + JSDocTemplateTag = 312, + JSDocTypedefTag = 313, + JSDocPropertyTag = 314, + SyntaxList = 315, + NotEmittedStatement = 316, + PartiallyEmittedExpression = 317, + CommaListExpression = 318, + MergeDeclarationMarker = 319, + EndOfDeclarationMarker = 320, + Count = 321, FirstAssignment = 60, LastAssignment = 72, FirstCompoundAssignment = 61, @@ -405,15 +406,15 @@ declare namespace ts { FirstReservedWord = 74, LastReservedWord = 109, FirstKeyword = 74, - LastKeyword = 148, + LastKeyword = 149, FirstFutureReservedWord = 110, LastFutureReservedWord = 118, - FirstTypeNode = 164, - LastTypeNode = 184, + FirstTypeNode = 165, + LastTypeNode = 185, FirstPunctuation = 18, LastPunctuation = 72, FirstToken = 0, - LastToken = 148, + LastToken = 149, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -422,11 +423,13 @@ declare namespace ts { LastTemplateToken = 17, FirstBinaryOperator = 28, LastBinaryOperator = 72, - FirstNode = 149, - FirstJSDocNode = 289, - LastJSDocNode = 313, - FirstJSDocTagNode = 301, - LastJSDocTagNode = 313, + FirstStatement = 222, + LastStatement = 238, + FirstNode = 150, + FirstJSDocNode = 290, + LastJSDocNode = 314, + FirstJSDocTagNode = 302, + LastJSDocTagNode = 314, } export enum NodeFlags { None = 0, @@ -517,6 +520,7 @@ declare namespace ts { export type AwaitKeywordToken = Token; export type PlusToken = Token; export type MinusToken = Token; + export type AssertsToken = Token; export type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; export type ModifiersArray = NodeArray; export interface Identifier extends PrimaryExpression, Declaration { @@ -770,8 +774,9 @@ declare namespace ts { export interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; parent: SignatureDeclaration | JSDocTypeExpression; + assertsModifier?: AssertsToken; parameterName: Identifier | ThisTypeNode; - type: TypeNode; + type?: TypeNode; } export interface TypeQueryNode extends TypeNode { kind: SyntaxKind.TypeQuery; @@ -1669,13 +1674,19 @@ declare namespace ts { FalseCondition = 64, SwitchClause = 128, ArrayMutation = 256, - Referenced = 512, - Shared = 1024, - PreFinally = 2048, - AfterFinally = 4096, + Call = 512, + Referenced = 1024, + Shared = 2048, + PreFinally = 4096, + AfterFinally = 8192, Label = 12, Condition = 96 } + export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCall | FlowCondition | FlowSwitchClause | FlowArrayMutation; + export interface FlowNodeBase { + flags: FlowFlags; + id?: number; + } export interface FlowLock { locked?: boolean; } @@ -1686,13 +1697,8 @@ declare namespace ts { antecedent: FlowNode; lock: FlowLock; } - export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation; - export interface FlowNodeBase { - flags: FlowFlags; - id?: number; - } export interface FlowStart extends FlowNodeBase { - container?: FunctionExpression | ArrowFunction | MethodDeclaration; + node?: FunctionExpression | ArrowFunction | MethodDeclaration; } export interface FlowLabel extends FlowNodeBase { antecedents: FlowNode[] | undefined; @@ -1701,8 +1707,12 @@ declare namespace ts { node: Expression | VariableDeclaration | BindingElement; antecedent: FlowNode; } + export interface FlowCall extends FlowNodeBase { + node: CallExpression; + antecedent: FlowNode; + } export interface FlowCondition extends FlowNodeBase { - expression: Expression; + node: Expression; antecedent: FlowNode; } export interface FlowSwitchClause extends FlowNodeBase { @@ -1957,6 +1967,7 @@ declare namespace ts { getReturnTypeOfSignature(signature: Signature): Type; getNullableType(type: Type, flags: TypeFlags): Type; getNonNullableType(type: Type): Type; + getTypeArguments(type: TypeReference): readonly Type[]; /** Note that the resulting nodes cannot be checked. */ typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode | undefined; /** Note that the resulting nodes cannot be checked. */ @@ -2098,21 +2109,39 @@ declare namespace ts { } export enum TypePredicateKind { This = 0, - Identifier = 1 + Identifier = 1, + AssertsThis = 2, + AssertsIdentifier = 3 } export interface TypePredicateBase { kind: TypePredicateKind; - type: Type; + type: Type | undefined; } export interface ThisTypePredicate extends TypePredicateBase { kind: TypePredicateKind.This; + parameterName: undefined; + parameterIndex: undefined; + type: Type; } export interface IdentifierTypePredicate extends TypePredicateBase { kind: TypePredicateKind.Identifier; parameterName: string; parameterIndex: number; + type: Type; } - export type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; + export interface AssertsThisTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.AssertsThis; + parameterName: undefined; + parameterIndex: undefined; + type: Type | undefined; + } + export interface AssertsIdentifierTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.AssertsIdentifier; + parameterName: string; + parameterIndex: number; + type: Type | undefined; + } + export type TypePredicate = ThisTypePredicate | IdentifierTypePredicate | AssertsThisTypePredicate | AssertsIdentifierTypePredicate; export enum SymbolFlags { None = 0, FunctionScopedVariable = 1, @@ -2340,7 +2369,7 @@ declare namespace ts { localTypeParameters: TypeParameter[] | undefined; thisType: TypeParameter | undefined; } - export type BaseType = ObjectType | IntersectionType; + export type BaseType = ObjectType | IntersectionType | TypeVariable; export interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; @@ -2360,7 +2389,9 @@ declare namespace ts { */ export interface TypeReference extends ObjectType { target: GenericType; - typeArguments?: readonly Type[]; + node?: TypeReferenceNode | ArrayTypeNode | TupleTypeNode; + } + export interface DeferredTypeReference extends TypeReference { } export interface GenericType extends InterfaceType, TypeReference { } @@ -2539,6 +2570,7 @@ declare namespace ts { emitDeclarationOnly?: boolean; declarationDir?: string; disableSizeLimit?: boolean; + disableSourceOfProjectReferenceRedirect?: boolean; downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; @@ -3845,7 +3877,9 @@ declare namespace ts { function updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode; function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode; + function createTypePredicateNodeWithModifier(assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode | string, type: TypeNode | undefined): TypePredicateNode; function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode; + function updateTypePredicateNodeWithModifier(node: TypePredicateNode, assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode, type: TypeNode | undefined): TypePredicateNode; function createTypeReferenceNode(typeName: string | EntityName, typeArguments: readonly TypeNode[] | undefined): TypeReferenceNode; function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray | undefined): TypeReferenceNode; function createFunctionTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode; diff --git a/tests/baselines/reference/arrayLiterals3.errors.txt b/tests/baselines/reference/arrayLiterals3.errors.txt index 4d398978c96..5f592b74f3e 100644 --- a/tests/baselines/reference/arrayLiterals3.errors.txt +++ b/tests/baselines/reference/arrayLiterals3.errors.txt @@ -8,10 +8,9 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(17,5): error tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(32,5): error TS2739: Type '(number[] | string[])[]' is missing the following properties from type 'tup': 0, 1 tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(33,5): error TS2739: Type 'number[]' is missing the following properties from type '[number, number, number]': 0, 1, 2 tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'. - Types of property 'pop' are incompatible. - Type '() => string | number' is not assignable to type '() => Number'. - Type 'string | number' is not assignable to type 'Number'. - Type 'string' is not assignable to type 'Number'. + The types returned by 'pop()' are incompatible between these types. + Type 'string | number' is not assignable to type 'Number'. + Type 'string' is not assignable to type 'Number'. ==== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts (8 errors) ==== @@ -67,8 +66,7 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error var c2: myArray = [...temp1, ...temp]; // Error cannot assign (number|string)[] to number[] ~~ !!! error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'. -!!! error TS2322: Types of property 'pop' are incompatible. -!!! error TS2322: Type '() => string | number' is not assignable to type '() => Number'. -!!! error TS2322: Type 'string | number' is not assignable to type 'Number'. -!!! error TS2322: Type 'string' is not assignable to type 'Number'. +!!! error TS2322: The types returned by 'pop()' are incompatible between these types. +!!! error TS2322: Type 'string | number' is not assignable to type 'Number'. +!!! error TS2322: Type 'string' is not assignable to type 'Number'. \ No newline at end of file diff --git a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt index 63d3a6f7b64..66b3c2c8691 100644 --- a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt +++ b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt @@ -1,10 +1,9 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(13,1): error TS2322: Type 'A[]' is not assignable to type 'readonly B[]'. Property 'b' is missing in type 'A' but required in type 'B'. tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error TS2322: Type 'C' is not assignable to type 'readonly B[]'. - Types of property 'concat' are incompatible. - Type '{ (...items: ConcatArray[]): A[]; (...items: (A | ConcatArray)[]): A[]; }' is not assignable to type '{ (...items: ConcatArray[]): B[]; (...items: (B | ConcatArray)[]): B[]; }'. - Type 'A[]' is not assignable to type 'B[]'. - Type 'A' is not assignable to type 'B'. + The types returned by 'concat(...)' are incompatible between these types. + Type 'A[]' is not assignable to type 'B[]'. + Type 'A' is not assignable to type 'B'. ==== tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts (2 errors) ==== @@ -32,8 +31,7 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error T rrb = cra; // error: 'A' is not assignable to 'B' ~~~ !!! error TS2322: Type 'C' is not assignable to type 'readonly B[]'. -!!! error TS2322: Types of property 'concat' are incompatible. -!!! error TS2322: Type '{ (...items: ConcatArray[]): A[]; (...items: (A | ConcatArray)[]): A[]; }' is not assignable to type '{ (...items: ConcatArray[]): B[]; (...items: (B | ConcatArray)[]): B[]; }'. -!!! error TS2322: Type 'A[]' is not assignable to type 'B[]'. -!!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: The types returned by 'concat(...)' are incompatible between these types. +!!! error TS2322: Type 'A[]' is not assignable to type 'B[]'. +!!! error TS2322: Type 'A' is not assignable to type 'B'. \ No newline at end of file diff --git a/tests/baselines/reference/assertionTypePredicates1.errors.txt b/tests/baselines/reference/assertionTypePredicates1.errors.txt new file mode 100644 index 00000000000..91d2e869bd2 --- /dev/null +++ b/tests/baselines/reference/assertionTypePredicates1.errors.txt @@ -0,0 +1,150 @@ +tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(116,37): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(117,37): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(118,37): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(121,15): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(122,15): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(123,15): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(124,15): error TS1228: A type predicate is only allowed in return type position for functions and methods. + + +==== tests/cases/conformance/controlFlow/assertionTypePredicates1.ts (7 errors) ==== + declare function isString(value: unknown): value is string; + declare function isArrayOfStrings(value: unknown): value is string[]; + + const assert: (value: unknown) => asserts value = value => {} + + declare function assertIsString(value: unknown): asserts value is string; + declare function assertIsArrayOfStrings(value: unknown): asserts value is string[]; + declare function assertDefined(value: T): asserts value is NonNullable; + + function f01(x: unknown) { + if (!!true) { + assert(typeof x === "string"); + x.length; + } + if (!!true) { + assert(x instanceof Error); + x.message; + } + if (!!true) { + assert(typeof x === "boolean" || typeof x === "number"); + x.toLocaleString; + } + if (!!true) { + assert(isArrayOfStrings(x)); + x[0].length; + } + if (!!true) { + assertIsArrayOfStrings(x); + x[0].length; + } + if (!!true) { + assert(x === undefined || typeof x === "string"); + x; // string | undefined + assertDefined(x); + x; // string + } + } + + function f02(x: string | undefined) { + if (!!true) { + assert(x); + x.length; + } + if (!!true) { + assert(x !== undefined); + x.length; + } + if (!!true) { + assertDefined(x); + x.length; + } + } + + function f03(x: string | undefined, assert: (value: unknown) => asserts value) { + assert(x); + x.length; + } + + namespace Debug { + export declare function assert(value: unknown, message?: string): asserts value; + export declare function assertDefined(value: T): asserts value is NonNullable; + } + + function f10(x: string | undefined) { + if (!!true) { + Debug.assert(x); + x.length; + } + if (!!true) { + Debug.assert(x !== undefined); + x.length; + } + if (!!true) { + Debug.assertDefined(x); + x.length; + } + } + + class Test { + assert(value: unknown): asserts value { + if (value) return; + throw new Error(); + } + isTest2(): this is Test2 { + return this instanceof Test2; + } + assertIsTest2(): asserts this is Test2 { + if (this instanceof Test2) return; + throw new Error(); + } + assertThis(): asserts this { + if (!this) return; + throw new Error(); + } + bar() { + this.assertThis(); + this; + } + foo(x: unknown) { + this.assert(typeof x === "string"); + x.length; + if (this.isTest2()) { + this.z; + } + this.assertIsTest2(); + this.z; + } + } + + class Test2 extends Test { + z = 0; + } + + // Invalid constructs + + declare let Q1: new (x: unknown) => x is string; + ~~~~~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. + declare let Q2: new (x: boolean) => asserts x; + ~~~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. + declare let Q3: new (x: unknown) => asserts x is string; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. + + declare class Wat { + get p1(): this is string; + ~~~~~~~~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. + set p1(x: this is string); + ~~~~~~~~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. + get p2(): asserts this is string; + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. + set p2(x: asserts this is string); + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. + } + \ No newline at end of file diff --git a/tests/baselines/reference/assertionTypePredicates1.js b/tests/baselines/reference/assertionTypePredicates1.js new file mode 100644 index 00000000000..ad21d116b73 --- /dev/null +++ b/tests/baselines/reference/assertionTypePredicates1.js @@ -0,0 +1,289 @@ +//// [assertionTypePredicates1.ts] +declare function isString(value: unknown): value is string; +declare function isArrayOfStrings(value: unknown): value is string[]; + +const assert: (value: unknown) => asserts value = value => {} + +declare function assertIsString(value: unknown): asserts value is string; +declare function assertIsArrayOfStrings(value: unknown): asserts value is string[]; +declare function assertDefined(value: T): asserts value is NonNullable; + +function f01(x: unknown) { + if (!!true) { + assert(typeof x === "string"); + x.length; + } + if (!!true) { + assert(x instanceof Error); + x.message; + } + if (!!true) { + assert(typeof x === "boolean" || typeof x === "number"); + x.toLocaleString; + } + if (!!true) { + assert(isArrayOfStrings(x)); + x[0].length; + } + if (!!true) { + assertIsArrayOfStrings(x); + x[0].length; + } + if (!!true) { + assert(x === undefined || typeof x === "string"); + x; // string | undefined + assertDefined(x); + x; // string + } +} + +function f02(x: string | undefined) { + if (!!true) { + assert(x); + x.length; + } + if (!!true) { + assert(x !== undefined); + x.length; + } + if (!!true) { + assertDefined(x); + x.length; + } +} + +function f03(x: string | undefined, assert: (value: unknown) => asserts value) { + assert(x); + x.length; +} + +namespace Debug { + export declare function assert(value: unknown, message?: string): asserts value; + export declare function assertDefined(value: T): asserts value is NonNullable; +} + +function f10(x: string | undefined) { + if (!!true) { + Debug.assert(x); + x.length; + } + if (!!true) { + Debug.assert(x !== undefined); + x.length; + } + if (!!true) { + Debug.assertDefined(x); + x.length; + } +} + +class Test { + assert(value: unknown): asserts value { + if (value) return; + throw new Error(); + } + isTest2(): this is Test2 { + return this instanceof Test2; + } + assertIsTest2(): asserts this is Test2 { + if (this instanceof Test2) return; + throw new Error(); + } + assertThis(): asserts this { + if (!this) return; + throw new Error(); + } + bar() { + this.assertThis(); + this; + } + foo(x: unknown) { + this.assert(typeof x === "string"); + x.length; + if (this.isTest2()) { + this.z; + } + this.assertIsTest2(); + this.z; + } +} + +class Test2 extends Test { + z = 0; +} + +// Invalid constructs + +declare let Q1: new (x: unknown) => x is string; +declare let Q2: new (x: boolean) => asserts x; +declare let Q3: new (x: unknown) => asserts x is string; + +declare class Wat { + get p1(): this is string; + set p1(x: this is string); + get p2(): asserts this is string; + set p2(x: asserts this is string); +} + + +//// [assertionTypePredicates1.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 assert = function (value) { }; +function f01(x) { + if (!!true) { + assert(typeof x === "string"); + x.length; + } + if (!!true) { + assert(x instanceof Error); + x.message; + } + if (!!true) { + assert(typeof x === "boolean" || typeof x === "number"); + x.toLocaleString; + } + if (!!true) { + assert(isArrayOfStrings(x)); + x[0].length; + } + if (!!true) { + assertIsArrayOfStrings(x); + x[0].length; + } + if (!!true) { + assert(x === undefined || typeof x === "string"); + x; // string | undefined + assertDefined(x); + x; // string + } +} +function f02(x) { + if (!!true) { + assert(x); + x.length; + } + if (!!true) { + assert(x !== undefined); + x.length; + } + if (!!true) { + assertDefined(x); + x.length; + } +} +function f03(x, assert) { + assert(x); + x.length; +} +var Debug; +(function (Debug) { +})(Debug || (Debug = {})); +function f10(x) { + if (!!true) { + Debug.assert(x); + x.length; + } + if (!!true) { + Debug.assert(x !== undefined); + x.length; + } + if (!!true) { + Debug.assertDefined(x); + x.length; + } +} +var Test = /** @class */ (function () { + function Test() { + } + Test.prototype.assert = function (value) { + if (value) + return; + throw new Error(); + }; + Test.prototype.isTest2 = function () { + return this instanceof Test2; + }; + Test.prototype.assertIsTest2 = function () { + if (this instanceof Test2) + return; + throw new Error(); + }; + Test.prototype.assertThis = function () { + if (!this) + return; + throw new Error(); + }; + Test.prototype.bar = function () { + this.assertThis(); + this; + }; + Test.prototype.foo = function (x) { + this.assert(typeof x === "string"); + x.length; + if (this.isTest2()) { + this.z; + } + this.assertIsTest2(); + this.z; + }; + return Test; +}()); +var Test2 = /** @class */ (function (_super) { + __extends(Test2, _super); + function Test2() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.z = 0; + return _this; + } + return Test2; +}(Test)); + + +//// [assertionTypePredicates1.d.ts] +declare function isString(value: unknown): value is string; +declare function isArrayOfStrings(value: unknown): value is string[]; +declare const assert: (value: unknown) => asserts value; +declare function assertIsString(value: unknown): asserts value is string; +declare function assertIsArrayOfStrings(value: unknown): asserts value is string[]; +declare function assertDefined(value: T): asserts value is NonNullable; +declare function f01(x: unknown): void; +declare function f02(x: string | undefined): void; +declare function f03(x: string | undefined, assert: (value: unknown) => asserts value): void; +declare namespace Debug { + function assert(value: unknown, message?: string): asserts value; + function assertDefined(value: T): asserts value is NonNullable; +} +declare function f10(x: string | undefined): void; +declare class Test { + assert(value: unknown): asserts value; + isTest2(): this is Test2; + assertIsTest2(): asserts this is Test2; + assertThis(): asserts this; + bar(): void; + foo(x: unknown): void; +} +declare class Test2 extends Test { + z: number; +} +declare let Q1: new (x: unknown) => x is string; +declare let Q2: new (x: boolean) => asserts x; +declare let Q3: new (x: unknown) => asserts x is string; +declare class Wat { + get p1(): this is string; + set p1(x: this is string); + get p2(): asserts this is string; + set p2(x: asserts this is string); +} diff --git a/tests/baselines/reference/assertionTypePredicates1.symbols b/tests/baselines/reference/assertionTypePredicates1.symbols new file mode 100644 index 00000000000..c68a1926aff --- /dev/null +++ b/tests/baselines/reference/assertionTypePredicates1.symbols @@ -0,0 +1,359 @@ +=== tests/cases/conformance/controlFlow/assertionTypePredicates1.ts === +declare function isString(value: unknown): value is string; +>isString : Symbol(isString, Decl(assertionTypePredicates1.ts, 0, 0)) +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 0, 26)) +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 0, 26)) + +declare function isArrayOfStrings(value: unknown): value is string[]; +>isArrayOfStrings : Symbol(isArrayOfStrings, Decl(assertionTypePredicates1.ts, 0, 59)) +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 1, 34)) +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 1, 34)) + +const assert: (value: unknown) => asserts value = value => {} +>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 3, 5)) +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 3, 15)) +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 3, 15)) +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 3, 49)) + +declare function assertIsString(value: unknown): asserts value is string; +>assertIsString : Symbol(assertIsString, Decl(assertionTypePredicates1.ts, 3, 61)) +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 5, 32)) +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 5, 32)) + +declare function assertIsArrayOfStrings(value: unknown): asserts value is string[]; +>assertIsArrayOfStrings : Symbol(assertIsArrayOfStrings, Decl(assertionTypePredicates1.ts, 5, 73)) +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 6, 40)) +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 6, 40)) + +declare function assertDefined(value: T): asserts value is NonNullable; +>assertDefined : Symbol(assertDefined, Decl(assertionTypePredicates1.ts, 6, 83)) +>T : Symbol(T, Decl(assertionTypePredicates1.ts, 7, 31)) +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 7, 34)) +>T : Symbol(T, Decl(assertionTypePredicates1.ts, 7, 31)) +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 7, 34)) +>NonNullable : Symbol(NonNullable, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(assertionTypePredicates1.ts, 7, 31)) + +function f01(x: unknown) { +>f01 : Symbol(f01, Decl(assertionTypePredicates1.ts, 7, 77)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13)) + + if (!!true) { + assert(typeof x === "string"); +>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 3, 5)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13)) + + x.length; +>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + } + if (!!true) { + assert(x instanceof Error); +>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 3, 5)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + x.message; +>x.message : Symbol(Error.message, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13)) +>message : Symbol(Error.message, Decl(lib.es5.d.ts, --, --)) + } + if (!!true) { + assert(typeof x === "boolean" || typeof x === "number"); +>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 3, 5)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13)) + + x.toLocaleString; +>x.toLocaleString : Symbol(toLocaleString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13)) +>toLocaleString : Symbol(toLocaleString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } + if (!!true) { + assert(isArrayOfStrings(x)); +>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 3, 5)) +>isArrayOfStrings : Symbol(isArrayOfStrings, Decl(assertionTypePredicates1.ts, 0, 59)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13)) + + x[0].length; +>x[0].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + } + if (!!true) { + assertIsArrayOfStrings(x); +>assertIsArrayOfStrings : Symbol(assertIsArrayOfStrings, Decl(assertionTypePredicates1.ts, 5, 73)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13)) + + x[0].length; +>x[0].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + } + if (!!true) { + assert(x === undefined || typeof x === "string"); +>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 3, 5)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13)) +>undefined : Symbol(undefined) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13)) + + x; // string | undefined +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13)) + + assertDefined(x); +>assertDefined : Symbol(assertDefined, Decl(assertionTypePredicates1.ts, 6, 83)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13)) + + x; // string +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13)) + } +} + +function f02(x: string | undefined) { +>f02 : Symbol(f02, Decl(assertionTypePredicates1.ts, 36, 1)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 38, 13)) + + if (!!true) { + assert(x); +>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 3, 5)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 38, 13)) + + x.length; +>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 38, 13)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + } + if (!!true) { + assert(x !== undefined); +>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 3, 5)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 38, 13)) +>undefined : Symbol(undefined) + + x.length; +>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 38, 13)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + } + if (!!true) { + assertDefined(x); +>assertDefined : Symbol(assertDefined, Decl(assertionTypePredicates1.ts, 6, 83)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 38, 13)) + + x.length; +>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 38, 13)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + } +} + +function f03(x: string | undefined, assert: (value: unknown) => asserts value) { +>f03 : Symbol(f03, Decl(assertionTypePredicates1.ts, 51, 1)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 53, 13)) +>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 53, 35)) +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 53, 45)) +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 53, 45)) + + assert(x); +>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 53, 35)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 53, 13)) + + x.length; +>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 53, 13)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +} + +namespace Debug { +>Debug : Symbol(Debug, Decl(assertionTypePredicates1.ts, 56, 1)) + + export declare function assert(value: unknown, message?: string): asserts value; +>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 58, 17)) +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 59, 35)) +>message : Symbol(message, Decl(assertionTypePredicates1.ts, 59, 50)) +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 59, 35)) + + export declare function assertDefined(value: T): asserts value is NonNullable; +>assertDefined : Symbol(assertDefined, Decl(assertionTypePredicates1.ts, 59, 84)) +>T : Symbol(T, Decl(assertionTypePredicates1.ts, 60, 42)) +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 60, 45)) +>T : Symbol(T, Decl(assertionTypePredicates1.ts, 60, 42)) +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 60, 45)) +>NonNullable : Symbol(NonNullable, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(assertionTypePredicates1.ts, 60, 42)) +} + +function f10(x: string | undefined) { +>f10 : Symbol(f10, Decl(assertionTypePredicates1.ts, 61, 1)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 63, 13)) + + if (!!true) { + Debug.assert(x); +>Debug.assert : Symbol(Debug.assert, Decl(assertionTypePredicates1.ts, 58, 17)) +>Debug : Symbol(Debug, Decl(assertionTypePredicates1.ts, 56, 1)) +>assert : Symbol(Debug.assert, Decl(assertionTypePredicates1.ts, 58, 17)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 63, 13)) + + x.length; +>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 63, 13)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + } + if (!!true) { + Debug.assert(x !== undefined); +>Debug.assert : Symbol(Debug.assert, Decl(assertionTypePredicates1.ts, 58, 17)) +>Debug : Symbol(Debug, Decl(assertionTypePredicates1.ts, 56, 1)) +>assert : Symbol(Debug.assert, Decl(assertionTypePredicates1.ts, 58, 17)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 63, 13)) +>undefined : Symbol(undefined) + + x.length; +>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 63, 13)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + } + if (!!true) { + Debug.assertDefined(x); +>Debug.assertDefined : Symbol(Debug.assertDefined, Decl(assertionTypePredicates1.ts, 59, 84)) +>Debug : Symbol(Debug, Decl(assertionTypePredicates1.ts, 56, 1)) +>assertDefined : Symbol(Debug.assertDefined, Decl(assertionTypePredicates1.ts, 59, 84)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 63, 13)) + + x.length; +>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 63, 13)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + } +} + +class Test { +>Test : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1)) + + assert(value: unknown): asserts value { +>assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 78, 12)) +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 79, 11)) +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 79, 11)) + + if (value) return; +>value : Symbol(value, Decl(assertionTypePredicates1.ts, 79, 11)) + + throw new Error(); +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } + isTest2(): this is Test2 { +>isTest2 : Symbol(Test.isTest2, Decl(assertionTypePredicates1.ts, 82, 5)) +>Test2 : Symbol(Test2, Decl(assertionTypePredicates1.ts, 107, 1)) + + return this instanceof Test2; +>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1)) +>Test2 : Symbol(Test2, Decl(assertionTypePredicates1.ts, 107, 1)) + } + assertIsTest2(): asserts this is Test2 { +>assertIsTest2 : Symbol(Test.assertIsTest2, Decl(assertionTypePredicates1.ts, 85, 5)) +>Test2 : Symbol(Test2, Decl(assertionTypePredicates1.ts, 107, 1)) + + if (this instanceof Test2) return; +>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1)) +>Test2 : Symbol(Test2, Decl(assertionTypePredicates1.ts, 107, 1)) + + throw new Error(); +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } + assertThis(): asserts this { +>assertThis : Symbol(Test.assertThis, Decl(assertionTypePredicates1.ts, 89, 5)) + + if (!this) return; +>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1)) + + throw new Error(); +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } + bar() { +>bar : Symbol(Test.bar, Decl(assertionTypePredicates1.ts, 93, 5)) + + this.assertThis(); +>this.assertThis : Symbol(Test.assertThis, Decl(assertionTypePredicates1.ts, 89, 5)) +>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1)) +>assertThis : Symbol(Test.assertThis, Decl(assertionTypePredicates1.ts, 89, 5)) + + this; +>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1)) + } + foo(x: unknown) { +>foo : Symbol(Test.foo, Decl(assertionTypePredicates1.ts, 97, 5)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 98, 8)) + + this.assert(typeof x === "string"); +>this.assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 78, 12)) +>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1)) +>assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 78, 12)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 98, 8)) + + x.length; +>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 98, 8)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + if (this.isTest2()) { +>this.isTest2 : Symbol(Test.isTest2, Decl(assertionTypePredicates1.ts, 82, 5)) +>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1)) +>isTest2 : Symbol(Test.isTest2, Decl(assertionTypePredicates1.ts, 82, 5)) + + this.z; +>this.z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 109, 26)) +>z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 109, 26)) + } + this.assertIsTest2(); +>this.assertIsTest2 : Symbol(Test.assertIsTest2, Decl(assertionTypePredicates1.ts, 85, 5)) +>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1)) +>assertIsTest2 : Symbol(Test.assertIsTest2, Decl(assertionTypePredicates1.ts, 85, 5)) + + this.z; +>this.z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 109, 26)) +>z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 109, 26)) + } +} + +class Test2 extends Test { +>Test2 : Symbol(Test2, Decl(assertionTypePredicates1.ts, 107, 1)) +>Test : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1)) + + z = 0; +>z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 109, 26)) +} + +// Invalid constructs + +declare let Q1: new (x: unknown) => x is string; +>Q1 : Symbol(Q1, Decl(assertionTypePredicates1.ts, 115, 11)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 115, 21)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 115, 21)) + +declare let Q2: new (x: boolean) => asserts x; +>Q2 : Symbol(Q2, Decl(assertionTypePredicates1.ts, 116, 11)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 116, 21)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 116, 21)) + +declare let Q3: new (x: unknown) => asserts x is string; +>Q3 : Symbol(Q3, Decl(assertionTypePredicates1.ts, 117, 11)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 117, 21)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 117, 21)) + +declare class Wat { +>Wat : Symbol(Wat, Decl(assertionTypePredicates1.ts, 117, 56)) + + get p1(): this is string; +>p1 : Symbol(Wat.p1, Decl(assertionTypePredicates1.ts, 119, 19), Decl(assertionTypePredicates1.ts, 120, 29)) + + set p1(x: this is string); +>p1 : Symbol(Wat.p1, Decl(assertionTypePredicates1.ts, 119, 19), Decl(assertionTypePredicates1.ts, 120, 29)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 121, 11)) + + get p2(): asserts this is string; +>p2 : Symbol(Wat.p2, Decl(assertionTypePredicates1.ts, 121, 30), Decl(assertionTypePredicates1.ts, 122, 37)) + + set p2(x: asserts this is string); +>p2 : Symbol(Wat.p2, Decl(assertionTypePredicates1.ts, 121, 30), Decl(assertionTypePredicates1.ts, 122, 37)) +>x : Symbol(x, Decl(assertionTypePredicates1.ts, 123, 11)) +} + diff --git a/tests/baselines/reference/assertionTypePredicates1.types b/tests/baselines/reference/assertionTypePredicates1.types new file mode 100644 index 00000000000..f72ec641013 --- /dev/null +++ b/tests/baselines/reference/assertionTypePredicates1.types @@ -0,0 +1,438 @@ +=== tests/cases/conformance/controlFlow/assertionTypePredicates1.ts === +declare function isString(value: unknown): value is string; +>isString : (value: unknown) => value is string +>value : unknown + +declare function isArrayOfStrings(value: unknown): value is string[]; +>isArrayOfStrings : (value: unknown) => value is string[] +>value : unknown + +const assert: (value: unknown) => asserts value = value => {} +>assert : (value: unknown) => asserts value +>value : unknown +>value => {} : (value: unknown) => void +>value : unknown + +declare function assertIsString(value: unknown): asserts value is string; +>assertIsString : (value: unknown) => asserts value is string +>value : unknown + +declare function assertIsArrayOfStrings(value: unknown): asserts value is string[]; +>assertIsArrayOfStrings : (value: unknown) => asserts value is string[] +>value : unknown + +declare function assertDefined(value: T): asserts value is NonNullable; +>assertDefined : (value: T) => asserts value is NonNullable +>value : T + +function f01(x: unknown) { +>f01 : (x: unknown) => void +>x : unknown + + if (!!true) { +>!!true : true +>!true : false +>true : true + + assert(typeof x === "string"); +>assert(typeof x === "string") : void +>assert : (value: unknown) => asserts value +>typeof x === "string" : boolean +>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : unknown +>"string" : "string" + + x.length; +>x.length : number +>x : string +>length : number + } + if (!!true) { +>!!true : true +>!true : false +>true : true + + assert(x instanceof Error); +>assert(x instanceof Error) : void +>assert : (value: unknown) => asserts value +>x instanceof Error : boolean +>x : unknown +>Error : ErrorConstructor + + x.message; +>x.message : string +>x : Error +>message : string + } + if (!!true) { +>!!true : true +>!true : false +>true : true + + assert(typeof x === "boolean" || typeof x === "number"); +>assert(typeof x === "boolean" || typeof x === "number") : void +>assert : (value: unknown) => asserts value +>typeof x === "boolean" || typeof x === "number" : boolean +>typeof x === "boolean" : boolean +>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : unknown +>"boolean" : "boolean" +>typeof x === "number" : boolean +>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : unknown +>"number" : "number" + + x.toLocaleString; +>x.toLocaleString : ((locales?: string | string[] | undefined, options?: Intl.NumberFormatOptions | undefined) => string) | (() => string) +>x : number | boolean +>toLocaleString : ((locales?: string | string[] | undefined, options?: Intl.NumberFormatOptions | undefined) => string) | (() => string) + } + if (!!true) { +>!!true : true +>!true : false +>true : true + + assert(isArrayOfStrings(x)); +>assert(isArrayOfStrings(x)) : void +>assert : (value: unknown) => asserts value +>isArrayOfStrings(x) : boolean +>isArrayOfStrings : (value: unknown) => value is string[] +>x : unknown + + x[0].length; +>x[0].length : number +>x[0] : string +>x : string[] +>0 : 0 +>length : number + } + if (!!true) { +>!!true : true +>!true : false +>true : true + + assertIsArrayOfStrings(x); +>assertIsArrayOfStrings(x) : void +>assertIsArrayOfStrings : (value: unknown) => asserts value is string[] +>x : unknown + + x[0].length; +>x[0].length : number +>x[0] : string +>x : string[] +>0 : 0 +>length : number + } + if (!!true) { +>!!true : true +>!true : false +>true : true + + assert(x === undefined || typeof x === "string"); +>assert(x === undefined || typeof x === "string") : void +>assert : (value: unknown) => asserts value +>x === undefined || typeof x === "string" : boolean +>x === undefined : boolean +>x : unknown +>undefined : undefined +>typeof x === "string" : boolean +>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : unknown +>"string" : "string" + + x; // string | undefined +>x : string | undefined + + assertDefined(x); +>assertDefined(x) : void +>assertDefined : (value: T) => asserts value is NonNullable +>x : string | undefined + + x; // string +>x : string + } +} + +function f02(x: string | undefined) { +>f02 : (x: string | undefined) => void +>x : string | undefined + + if (!!true) { +>!!true : true +>!true : false +>true : true + + assert(x); +>assert(x) : void +>assert : (value: unknown) => asserts value +>x : string | undefined + + x.length; +>x.length : number +>x : string +>length : number + } + if (!!true) { +>!!true : true +>!true : false +>true : true + + assert(x !== undefined); +>assert(x !== undefined) : void +>assert : (value: unknown) => asserts value +>x !== undefined : boolean +>x : string | undefined +>undefined : undefined + + x.length; +>x.length : number +>x : string +>length : number + } + if (!!true) { +>!!true : true +>!true : false +>true : true + + assertDefined(x); +>assertDefined(x) : void +>assertDefined : (value: T) => asserts value is NonNullable +>x : string | undefined + + x.length; +>x.length : number +>x : string +>length : number + } +} + +function f03(x: string | undefined, assert: (value: unknown) => asserts value) { +>f03 : (x: string | undefined, assert: (value: unknown) => asserts value) => void +>x : string | undefined +>assert : (value: unknown) => asserts value +>value : unknown + + assert(x); +>assert(x) : void +>assert : (value: unknown) => asserts value +>x : string | undefined + + x.length; +>x.length : number +>x : string +>length : number +} + +namespace Debug { +>Debug : typeof Debug + + export declare function assert(value: unknown, message?: string): asserts value; +>assert : (value: unknown, message?: string | undefined) => asserts value +>value : unknown +>message : string | undefined + + export declare function assertDefined(value: T): asserts value is NonNullable; +>assertDefined : (value: T) => asserts value is NonNullable +>value : T +} + +function f10(x: string | undefined) { +>f10 : (x: string | undefined) => void +>x : string | undefined + + if (!!true) { +>!!true : true +>!true : false +>true : true + + Debug.assert(x); +>Debug.assert(x) : void +>Debug.assert : (value: unknown, message?: string | undefined) => asserts value +>Debug : typeof Debug +>assert : (value: unknown, message?: string | undefined) => asserts value +>x : string | undefined + + x.length; +>x.length : number +>x : string +>length : number + } + if (!!true) { +>!!true : true +>!true : false +>true : true + + Debug.assert(x !== undefined); +>Debug.assert(x !== undefined) : void +>Debug.assert : (value: unknown, message?: string | undefined) => asserts value +>Debug : typeof Debug +>assert : (value: unknown, message?: string | undefined) => asserts value +>x !== undefined : boolean +>x : string | undefined +>undefined : undefined + + x.length; +>x.length : number +>x : string +>length : number + } + if (!!true) { +>!!true : true +>!true : false +>true : true + + Debug.assertDefined(x); +>Debug.assertDefined(x) : void +>Debug.assertDefined : (value: T) => asserts value is NonNullable +>Debug : typeof Debug +>assertDefined : (value: T) => asserts value is NonNullable +>x : string | undefined + + x.length; +>x.length : number +>x : string +>length : number + } +} + +class Test { +>Test : Test + + assert(value: unknown): asserts value { +>assert : (value: unknown) => asserts value +>value : unknown + + if (value) return; +>value : unknown + + throw new Error(); +>new Error() : Error +>Error : ErrorConstructor + } + isTest2(): this is Test2 { +>isTest2 : () => this is Test2 + + return this instanceof Test2; +>this instanceof Test2 : boolean +>this : this +>Test2 : typeof Test2 + } + assertIsTest2(): asserts this is Test2 { +>assertIsTest2 : () => asserts this is Test2 + + if (this instanceof Test2) return; +>this instanceof Test2 : boolean +>this : this +>Test2 : typeof Test2 + + throw new Error(); +>new Error() : Error +>Error : ErrorConstructor + } + assertThis(): asserts this { +>assertThis : () => asserts this + + if (!this) return; +>!this : false +>this : this + + throw new Error(); +>new Error() : Error +>Error : ErrorConstructor + } + bar() { +>bar : () => void + + this.assertThis(); +>this.assertThis() : void +>this.assertThis : () => asserts this +>this : this +>assertThis : () => asserts this + + this; +>this : this + } + foo(x: unknown) { +>foo : (x: unknown) => void +>x : unknown + + this.assert(typeof x === "string"); +>this.assert(typeof x === "string") : void +>this.assert : (value: unknown) => asserts value +>this : this +>assert : (value: unknown) => asserts value +>typeof x === "string" : boolean +>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : unknown +>"string" : "string" + + x.length; +>x.length : number +>x : string +>length : number + + if (this.isTest2()) { +>this.isTest2() : boolean +>this.isTest2 : () => this is Test2 +>this : this +>isTest2 : () => this is Test2 + + this.z; +>this.z : number +>this : this & Test2 +>z : number + } + this.assertIsTest2(); +>this.assertIsTest2() : void +>this.assertIsTest2 : () => asserts this is Test2 +>this : this +>assertIsTest2 : () => asserts this is Test2 + + this.z; +>this.z : number +>this : this & Test2 +>z : number + } +} + +class Test2 extends Test { +>Test2 : Test2 +>Test : Test + + z = 0; +>z : number +>0 : 0 +} + +// Invalid constructs + +declare let Q1: new (x: unknown) => x is string; +>Q1 : new (x: unknown) => x is string +>x : unknown + +declare let Q2: new (x: boolean) => asserts x; +>Q2 : new (x: boolean) => asserts x +>x : boolean + +declare let Q3: new (x: unknown) => asserts x is string; +>Q3 : new (x: unknown) => asserts x is string +>x : unknown + +declare class Wat { +>Wat : Wat + + get p1(): this is string; +>p1 : boolean + + set p1(x: this is string); +>p1 : boolean +>x : boolean + + get p2(): asserts this is string; +>p2 : void + + set p2(x: asserts this is string); +>p2 : void +>x : void +} + diff --git a/tests/baselines/reference/assertionsAndNonReturningFunctions.errors.txt b/tests/baselines/reference/assertionsAndNonReturningFunctions.errors.txt new file mode 100644 index 00000000000..e1648d7643d --- /dev/null +++ b/tests/baselines/reference/assertionsAndNonReturningFunctions.errors.txt @@ -0,0 +1,69 @@ +tests/cases/conformance/jsdoc/assertionsAndNonReturningFunctions.js(46,9): error TS7027: Unreachable code detected. +tests/cases/conformance/jsdoc/assertionsAndNonReturningFunctions.js(58,5): error TS7027: Unreachable code detected. + + +==== tests/cases/conformance/jsdoc/assertionsAndNonReturningFunctions.js (2 errors) ==== + /** @typedef {(check: boolean) => asserts check} AssertFunc */ + + /** @type {AssertFunc} */ + const assert = check => { + if (!check) throw new Error(); + } + + /** @type {(x: unknown) => asserts x is string } */ + function assertIsString(x) { + if (!(typeof x === "string")) throw new Error(); + } + + /** + * @param {boolean} check + * @returns {asserts check} + */ + function assert2(check) { + if (!check) throw new Error(); + } + + /** + * @returns {never} + */ + function fail() { + throw new Error(); + } + + /** + * @param {*} x + */ + function f1(x) { + if (!!true) { + assert(typeof x === "string"); + x.length; + } + if (!!true) { + assert2(typeof x === "string"); + x.length; + } + if (!!true) { + assertIsString(x); + x.length; + } + if (!!true) { + fail(); + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + } + + /** + * @param {boolean} b + */ + function f2(b) { + switch (b) { + case true: return 1; + case false: return 0; + } + b; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + \ No newline at end of file diff --git a/tests/baselines/reference/assertionsAndNonReturningFunctions.symbols b/tests/baselines/reference/assertionsAndNonReturningFunctions.symbols new file mode 100644 index 00000000000..88931cffbd8 --- /dev/null +++ b/tests/baselines/reference/assertionsAndNonReturningFunctions.symbols @@ -0,0 +1,109 @@ +=== tests/cases/conformance/jsdoc/assertionsAndNonReturningFunctions.js === +/** @typedef {(check: boolean) => asserts check} AssertFunc */ + +/** @type {AssertFunc} */ +const assert = check => { +>assert : Symbol(assert, Decl(assertionsAndNonReturningFunctions.js, 3, 5)) +>check : Symbol(check, Decl(assertionsAndNonReturningFunctions.js, 3, 14)) + + if (!check) throw new Error(); +>check : Symbol(check, Decl(assertionsAndNonReturningFunctions.js, 3, 14)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +} + +/** @type {(x: unknown) => asserts x is string } */ +function assertIsString(x) { +>assertIsString : Symbol(assertIsString, Decl(assertionsAndNonReturningFunctions.js, 5, 1)) +>x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 8, 24)) + + if (!(typeof x === "string")) throw new Error(); +>x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 8, 24)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +} + +/** + * @param {boolean} check + * @returns {asserts check} +*/ +function assert2(check) { +>assert2 : Symbol(assert2, Decl(assertionsAndNonReturningFunctions.js, 10, 1)) +>check : Symbol(check, Decl(assertionsAndNonReturningFunctions.js, 16, 17)) + + if (!check) throw new Error(); +>check : Symbol(check, Decl(assertionsAndNonReturningFunctions.js, 16, 17)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +} + +/** + * @returns {never} + */ +function fail() { +>fail : Symbol(fail, Decl(assertionsAndNonReturningFunctions.js, 18, 1)) + + throw new Error(); +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +} + +/** + * @param {*} x + */ +function f1(x) { +>f1 : Symbol(f1, Decl(assertionsAndNonReturningFunctions.js, 25, 1)) +>x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12)) + + if (!!true) { + assert(typeof x === "string"); +>assert : Symbol(assert, Decl(assertionsAndNonReturningFunctions.js, 3, 5)) +>x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12)) + + x.length; +>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + } + if (!!true) { + assert2(typeof x === "string"); +>assert2 : Symbol(assert2, Decl(assertionsAndNonReturningFunctions.js, 10, 1)) +>x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12)) + + x.length; +>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + } + if (!!true) { + assertIsString(x); +>assertIsString : Symbol(assertIsString, Decl(assertionsAndNonReturningFunctions.js, 5, 1)) +>x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12)) + + x.length; +>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + } + if (!!true) { + fail(); +>fail : Symbol(fail, Decl(assertionsAndNonReturningFunctions.js, 18, 1)) + + x; // Unreachable +>x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12)) + } +} + +/** + * @param {boolean} b + */ +function f2(b) { +>f2 : Symbol(f2, Decl(assertionsAndNonReturningFunctions.js, 47, 1)) +>b : Symbol(b, Decl(assertionsAndNonReturningFunctions.js, 52, 12)) + + switch (b) { +>b : Symbol(b, Decl(assertionsAndNonReturningFunctions.js, 52, 12)) + + case true: return 1; + case false: return 0; + } + b; // Unreachable +>b : Symbol(b, Decl(assertionsAndNonReturningFunctions.js, 52, 12)) +} + diff --git a/tests/baselines/reference/assertionsAndNonReturningFunctions.types b/tests/baselines/reference/assertionsAndNonReturningFunctions.types new file mode 100644 index 00000000000..32100b6c3d2 --- /dev/null +++ b/tests/baselines/reference/assertionsAndNonReturningFunctions.types @@ -0,0 +1,152 @@ +=== tests/cases/conformance/jsdoc/assertionsAndNonReturningFunctions.js === +/** @typedef {(check: boolean) => asserts check} AssertFunc */ + +/** @type {AssertFunc} */ +const assert = check => { +>assert : (check: boolean) => asserts check +>check => { if (!check) throw new Error();} : (check: boolean) => asserts check +>check : boolean + + if (!check) throw new Error(); +>!check : boolean +>check : boolean +>new Error() : Error +>Error : ErrorConstructor +} + +/** @type {(x: unknown) => asserts x is string } */ +function assertIsString(x) { +>assertIsString : (x: unknown) => asserts x is string +>x : unknown + + if (!(typeof x === "string")) throw new Error(); +>!(typeof x === "string") : boolean +>(typeof x === "string") : boolean +>typeof x === "string" : boolean +>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : unknown +>"string" : "string" +>new Error() : Error +>Error : ErrorConstructor +} + +/** + * @param {boolean} check + * @returns {asserts check} +*/ +function assert2(check) { +>assert2 : (check: boolean) => asserts check +>check : boolean + + if (!check) throw new Error(); +>!check : boolean +>check : boolean +>new Error() : Error +>Error : ErrorConstructor +} + +/** + * @returns {never} + */ +function fail() { +>fail : () => never + + throw new Error(); +>new Error() : Error +>Error : ErrorConstructor +} + +/** + * @param {*} x + */ +function f1(x) { +>f1 : (x: any) => void +>x : any + + if (!!true) { +>!!true : boolean +>!true : boolean +>true : true + + assert(typeof x === "string"); +>assert(typeof x === "string") : void +>assert : (check: boolean) => asserts check +>typeof x === "string" : boolean +>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : any +>"string" : "string" + + x.length; +>x.length : number +>x : string +>length : number + } + if (!!true) { +>!!true : boolean +>!true : boolean +>true : true + + assert2(typeof x === "string"); +>assert2(typeof x === "string") : void +>assert2 : (check: boolean) => asserts check +>typeof x === "string" : boolean +>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : any +>"string" : "string" + + x.length; +>x.length : number +>x : string +>length : number + } + if (!!true) { +>!!true : boolean +>!true : boolean +>true : true + + assertIsString(x); +>assertIsString(x) : void +>assertIsString : (x: unknown) => asserts x is string +>x : any + + x.length; +>x.length : number +>x : string +>length : number + } + if (!!true) { +>!!true : boolean +>!true : boolean +>true : true + + fail(); +>fail() : never +>fail : () => never + + x; // Unreachable +>x : any + } +} + +/** + * @param {boolean} b + */ +function f2(b) { +>f2 : (b: boolean) => 1 | 0 +>b : boolean + + switch (b) { +>b : boolean + + case true: return 1; +>true : true +>1 : 1 + + case false: return 0; +>false : false +>0 : 0 + } + b; // Unreachable +>b : never +} + diff --git a/tests/baselines/reference/assignFromBooleanInterface2.errors.txt b/tests/baselines/reference/assignFromBooleanInterface2.errors.txt index 6c7ebbe5ee8..ba8b2f5a9c9 100644 --- a/tests/baselines/reference/assignFromBooleanInterface2.errors.txt +++ b/tests/baselines/reference/assignFromBooleanInterface2.errors.txt @@ -1,7 +1,6 @@ tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts(14,1): error TS2322: Type 'NotBoolean' is not assignable to type 'Boolean'. - Types of property 'valueOf' are incompatible. - Type '() => Object' is not assignable to type '() => boolean'. - Type 'Object' is not assignable to type 'boolean'. + The types returned by 'valueOf()' are incompatible between these types. + Type 'Object' is not assignable to type 'boolean'. tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts(19,1): error TS2322: Type 'Boolean' is not assignable to type 'boolean'. 'boolean' is a primitive, but 'Boolean' is a wrapper object. Prefer using 'boolean' when possible. tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts(20,1): error TS2322: Type 'NotBoolean' is not assignable to type 'boolean'. @@ -24,9 +23,8 @@ tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts( a = b; ~ !!! error TS2322: Type 'NotBoolean' is not assignable to type 'Boolean'. -!!! error TS2322: Types of property 'valueOf' are incompatible. -!!! error TS2322: Type '() => Object' is not assignable to type '() => boolean'. -!!! error TS2322: Type 'Object' is not assignable to type 'boolean'. +!!! error TS2322: The types returned by 'valueOf()' are incompatible between these types. +!!! error TS2322: Type 'Object' is not assignable to type 'boolean'. b = a; b = x; diff --git a/tests/baselines/reference/asyncAliasReturnType_es5.types b/tests/baselines/reference/asyncAliasReturnType_es5.types index 87090b795e3..22ca9c932b3 100644 --- a/tests/baselines/reference/asyncAliasReturnType_es5.types +++ b/tests/baselines/reference/asyncAliasReturnType_es5.types @@ -1,7 +1,7 @@ === tests/cases/conformance/async/es5/asyncAliasReturnType_es5.ts === type PromiseAlias = Promise; ->PromiseAlias : Promise +>PromiseAlias : PromiseAlias async function f(): PromiseAlias { ->f : () => Promise +>f : () => PromiseAlias } diff --git a/tests/baselines/reference/asyncAliasReturnType_es6.types b/tests/baselines/reference/asyncAliasReturnType_es6.types index 85d74896056..943856611b5 100644 --- a/tests/baselines/reference/asyncAliasReturnType_es6.types +++ b/tests/baselines/reference/asyncAliasReturnType_es6.types @@ -1,7 +1,7 @@ === tests/cases/conformance/async/es6/asyncAliasReturnType_es6.ts === type PromiseAlias = Promise; ->PromiseAlias : Promise +>PromiseAlias : PromiseAlias async function f(): PromiseAlias { ->f : () => Promise +>f : () => PromiseAlias } diff --git a/tests/baselines/reference/asyncAwait_es2017.types b/tests/baselines/reference/asyncAwait_es2017.types index 4d657ab2ca3..c3fecf0f7c8 100644 --- a/tests/baselines/reference/asyncAwait_es2017.types +++ b/tests/baselines/reference/asyncAwait_es2017.types @@ -1,6 +1,6 @@ === tests/cases/conformance/async/es2017/asyncAwait_es2017.ts === type MyPromise = Promise; ->MyPromise : Promise +>MyPromise : MyPromise declare var MyPromise: typeof Promise; >MyPromise : PromiseConstructor @@ -10,7 +10,7 @@ declare var p: Promise; >p : Promise declare var mp: MyPromise; ->mp : Promise +>mp : MyPromise async function f0() { } >f0 : () => Promise @@ -19,7 +19,7 @@ async function f1(): Promise { } >f1 : () => Promise async function f3(): MyPromise { } ->f3 : () => Promise +>f3 : () => MyPromise let f4 = async function() { } >f4 : () => Promise @@ -30,8 +30,8 @@ let f5 = async function(): Promise { } >async function(): Promise { } : () => Promise let f6 = async function(): MyPromise { } ->f6 : () => Promise ->async function(): MyPromise { } : () => Promise +>f6 : () => MyPromise +>async function(): MyPromise { } : () => MyPromise let f7 = async () => { }; >f7 : () => Promise @@ -42,8 +42,8 @@ let f8 = async (): Promise => { }; >async (): Promise => { } : () => Promise let f9 = async (): MyPromise => { }; ->f9 : () => Promise ->async (): MyPromise => { } : () => Promise +>f9 : () => MyPromise +>async (): MyPromise => { } : () => MyPromise let f10 = async () => p; >f10 : () => Promise @@ -53,21 +53,21 @@ let f10 = async () => p; let f11 = async () => mp; >f11 : () => Promise >async () => mp : () => Promise ->mp : Promise +>mp : MyPromise let f12 = async (): Promise => mp; >f12 : () => Promise >async (): Promise => mp : () => Promise ->mp : Promise +>mp : MyPromise let f13 = async (): MyPromise => p; ->f13 : () => Promise ->async (): MyPromise => p : () => Promise +>f13 : () => MyPromise +>async (): MyPromise => p : () => MyPromise >p : Promise let o = { ->o : { m1(): Promise; m2(): Promise; m3(): Promise; } ->{ async m1() { }, async m2(): Promise { }, async m3(): MyPromise { }} : { m1(): Promise; m2(): Promise; m3(): Promise; } +>o : { m1(): Promise; m2(): Promise; m3(): MyPromise; } +>{ async m1() { }, async m2(): Promise { }, async m3(): MyPromise { }} : { m1(): Promise; m2(): Promise; m3(): MyPromise; } async m1() { }, >m1 : () => Promise @@ -76,7 +76,7 @@ let o = { >m2 : () => Promise async m3(): MyPromise { } ->m3 : () => Promise +>m3 : () => MyPromise }; @@ -90,7 +90,7 @@ class C { >m2 : () => Promise async m3(): MyPromise { } ->m3 : () => Promise +>m3 : () => MyPromise static async m4() { } >m4 : () => Promise @@ -99,7 +99,7 @@ class C { >m5 : () => Promise static async m6(): MyPromise { } ->m6 : () => Promise +>m6 : () => MyPromise } module M { diff --git a/tests/baselines/reference/asyncAwait_es5.types b/tests/baselines/reference/asyncAwait_es5.types index fb10a6dd043..be62067c301 100644 --- a/tests/baselines/reference/asyncAwait_es5.types +++ b/tests/baselines/reference/asyncAwait_es5.types @@ -1,6 +1,6 @@ === tests/cases/conformance/async/es5/asyncAwait_es5.ts === type MyPromise = Promise; ->MyPromise : Promise +>MyPromise : MyPromise declare var MyPromise: typeof Promise; >MyPromise : PromiseConstructor @@ -10,7 +10,7 @@ declare var p: Promise; >p : Promise declare var mp: MyPromise; ->mp : Promise +>mp : MyPromise async function f0() { } >f0 : () => Promise @@ -19,7 +19,7 @@ async function f1(): Promise { } >f1 : () => Promise async function f3(): MyPromise { } ->f3 : () => Promise +>f3 : () => MyPromise let f4 = async function() { } >f4 : () => Promise @@ -30,8 +30,8 @@ let f5 = async function(): Promise { } >async function(): Promise { } : () => Promise let f6 = async function(): MyPromise { } ->f6 : () => Promise ->async function(): MyPromise { } : () => Promise +>f6 : () => MyPromise +>async function(): MyPromise { } : () => MyPromise let f7 = async () => { }; >f7 : () => Promise @@ -42,8 +42,8 @@ let f8 = async (): Promise => { }; >async (): Promise => { } : () => Promise let f9 = async (): MyPromise => { }; ->f9 : () => Promise ->async (): MyPromise => { } : () => Promise +>f9 : () => MyPromise +>async (): MyPromise => { } : () => MyPromise let f10 = async () => p; >f10 : () => Promise @@ -53,21 +53,21 @@ let f10 = async () => p; let f11 = async () => mp; >f11 : () => Promise >async () => mp : () => Promise ->mp : Promise +>mp : MyPromise let f12 = async (): Promise => mp; >f12 : () => Promise >async (): Promise => mp : () => Promise ->mp : Promise +>mp : MyPromise let f13 = async (): MyPromise => p; ->f13 : () => Promise ->async (): MyPromise => p : () => Promise +>f13 : () => MyPromise +>async (): MyPromise => p : () => MyPromise >p : Promise let o = { ->o : { m1(): Promise; m2(): Promise; m3(): Promise; } ->{ async m1() { }, async m2(): Promise { }, async m3(): MyPromise { }} : { m1(): Promise; m2(): Promise; m3(): Promise; } +>o : { m1(): Promise; m2(): Promise; m3(): MyPromise; } +>{ async m1() { }, async m2(): Promise { }, async m3(): MyPromise { }} : { m1(): Promise; m2(): Promise; m3(): MyPromise; } async m1() { }, >m1 : () => Promise @@ -76,7 +76,7 @@ let o = { >m2 : () => Promise async m3(): MyPromise { } ->m3 : () => Promise +>m3 : () => MyPromise }; @@ -90,7 +90,7 @@ class C { >m2 : () => Promise async m3(): MyPromise { } ->m3 : () => Promise +>m3 : () => MyPromise static async m4() { } >m4 : () => Promise @@ -99,7 +99,7 @@ class C { >m5 : () => Promise static async m6(): MyPromise { } ->m6 : () => Promise +>m6 : () => MyPromise } module M { diff --git a/tests/baselines/reference/asyncAwait_es6.types b/tests/baselines/reference/asyncAwait_es6.types index cd9a05ee48e..3933b9ce7da 100644 --- a/tests/baselines/reference/asyncAwait_es6.types +++ b/tests/baselines/reference/asyncAwait_es6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/async/es6/asyncAwait_es6.ts === type MyPromise = Promise; ->MyPromise : Promise +>MyPromise : MyPromise declare var MyPromise: typeof Promise; >MyPromise : PromiseConstructor @@ -10,7 +10,7 @@ declare var p: Promise; >p : Promise declare var mp: MyPromise; ->mp : Promise +>mp : MyPromise async function f0() { } >f0 : () => Promise @@ -19,7 +19,7 @@ async function f1(): Promise { } >f1 : () => Promise async function f3(): MyPromise { } ->f3 : () => Promise +>f3 : () => MyPromise let f4 = async function() { } >f4 : () => Promise @@ -30,8 +30,8 @@ let f5 = async function(): Promise { } >async function(): Promise { } : () => Promise let f6 = async function(): MyPromise { } ->f6 : () => Promise ->async function(): MyPromise { } : () => Promise +>f6 : () => MyPromise +>async function(): MyPromise { } : () => MyPromise let f7 = async () => { }; >f7 : () => Promise @@ -42,8 +42,8 @@ let f8 = async (): Promise => { }; >async (): Promise => { } : () => Promise let f9 = async (): MyPromise => { }; ->f9 : () => Promise ->async (): MyPromise => { } : () => Promise +>f9 : () => MyPromise +>async (): MyPromise => { } : () => MyPromise let f10 = async () => p; >f10 : () => Promise @@ -53,21 +53,21 @@ let f10 = async () => p; let f11 = async () => mp; >f11 : () => Promise >async () => mp : () => Promise ->mp : Promise +>mp : MyPromise let f12 = async (): Promise => mp; >f12 : () => Promise >async (): Promise => mp : () => Promise ->mp : Promise +>mp : MyPromise let f13 = async (): MyPromise => p; ->f13 : () => Promise ->async (): MyPromise => p : () => Promise +>f13 : () => MyPromise +>async (): MyPromise => p : () => MyPromise >p : Promise let o = { ->o : { m1(): Promise; m2(): Promise; m3(): Promise; } ->{ async m1() { }, async m2(): Promise { }, async m3(): MyPromise { }} : { m1(): Promise; m2(): Promise; m3(): Promise; } +>o : { m1(): Promise; m2(): Promise; m3(): MyPromise; } +>{ async m1() { }, async m2(): Promise { }, async m3(): MyPromise { }} : { m1(): Promise; m2(): Promise; m3(): MyPromise; } async m1() { }, >m1 : () => Promise @@ -76,7 +76,7 @@ let o = { >m2 : () => Promise async m3(): MyPromise { } ->m3 : () => Promise +>m3 : () => MyPromise }; @@ -90,7 +90,7 @@ class C { >m2 : () => Promise async m3(): MyPromise { } ->m3 : () => Promise +>m3 : () => MyPromise static async m4() { } >m4 : () => Promise @@ -99,7 +99,7 @@ class C { >m5 : () => Promise static async m6(): MyPromise { } ->m6 : () => Promise +>m6 : () => MyPromise } module M { diff --git a/tests/baselines/reference/asyncFunctionDeclaration15_es5.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration15_es5.errors.txt index 6b4b0a71c6f..7e3595ec6f4 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration15_es5.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration15_es5.errors.txt @@ -5,10 +5,9 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1 tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(8,23): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(9,23): error TS1055: Type 'PromiseLike' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(10,23): error TS1055: Type 'typeof Thenable' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. - Type 'Thenable' is not assignable to type 'PromiseLike'. - Types of property 'then' are incompatible. - Type '() => void' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. - Type 'void' is not assignable to type 'PromiseLike'. + Construct signature return types 'Thenable' and 'PromiseLike' are incompatible. + The types returned by 'then(...)' are incompatible between these types. + Type 'void' is not assignable to type 'PromiseLike'. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(17,16): error TS1058: The return type of an async function must either be a valid promise or must not contain a callable 'then' member. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(23,25): error TS1320: Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member. @@ -38,10 +37,9 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1 async function fn6(): Thenable { } // error ~~~~~~~~ !!! error TS1055: Type 'typeof Thenable' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. -!!! error TS1055: Type 'Thenable' is not assignable to type 'PromiseLike'. -!!! error TS1055: Types of property 'then' are incompatible. -!!! error TS1055: Type '() => void' is not assignable to type '(onfulfilled?: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. -!!! error TS1055: Type 'void' is not assignable to type 'PromiseLike'. +!!! error TS1055: Construct signature return types 'Thenable' and 'PromiseLike' are incompatible. +!!! error TS1055: The types returned by 'then(...)' are incompatible between these types. +!!! error TS1055: Type 'void' is not assignable to type 'PromiseLike'. async function fn7() { return; } // valid: Promise async function fn8() { return 1; } // valid: Promise async function fn9() { return null; } // valid: Promise diff --git a/tests/baselines/reference/baseConstraintOfDecorator.errors.txt b/tests/baselines/reference/baseConstraintOfDecorator.errors.txt index 8317e5c55c6..8aad9f6fead 100644 --- a/tests/baselines/reference/baseConstraintOfDecorator.errors.txt +++ b/tests/baselines/reference/baseConstraintOfDecorator.errors.txt @@ -1,11 +1,10 @@ tests/cases/compiler/baseConstraintOfDecorator.ts(2,5): error TS2322: Type 'typeof decoratorFunc' is not assignable to type 'TFunction'. 'typeof decoratorFunc' is assignable to the constraint of type 'TFunction', but 'TFunction' could be instantiated with a different subtype of constraint '{}'. tests/cases/compiler/baseConstraintOfDecorator.ts(2,40): error TS2507: Type 'TFunction' is not a constructor function type. -tests/cases/compiler/baseConstraintOfDecorator.ts(12,5): error TS2322: Type 'typeof decoratorFunc' is not assignable to type 'TFunction'. -tests/cases/compiler/baseConstraintOfDecorator.ts(12,40): error TS2507: Type 'TFunction' is not a constructor function type. +tests/cases/compiler/baseConstraintOfDecorator.ts(12,18): error TS2545: A mixin class must have a constructor with a single rest parameter of type 'any[]'. -==== tests/cases/compiler/baseConstraintOfDecorator.ts (4 errors) ==== +==== tests/cases/compiler/baseConstraintOfDecorator.ts (3 errors) ==== export function classExtender(superClass: TFunction, _instanceModifier: (instance: any, args: any[]) => void): TFunction { return class decoratorFunc extends superClass { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -29,20 +28,12 @@ tests/cases/compiler/baseConstraintOfDecorator.ts(12,40): error TS2507: Type 'TF class MyClass { private x; } export function classExtender2 MyClass>(superClass: TFunction, _instanceModifier: (instance: any, args: any[]) => void): TFunction { return class decoratorFunc extends superClass { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~~~~~~~~~~ -!!! error TS2507: Type 'TFunction' is not a constructor function type. -!!! related TS2735 tests/cases/compiler/baseConstraintOfDecorator.ts:11:32: Did you mean for 'TFunction' to be constrained to type 'new (...args: any[]) => MyClass'? + ~~~~~~~~~~~~~ +!!! error TS2545: A mixin class must have a constructor with a single rest parameter of type 'any[]'. constructor(...args: any[]) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ super(...args); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ _instanceModifier(this, args); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } - ~~~~~~~~~ }; - ~~~~~~ -!!! error TS2322: Type 'typeof decoratorFunc' is not assignable to type 'TFunction'. } \ No newline at end of file diff --git a/tests/baselines/reference/baseConstraintOfDecorator.symbols b/tests/baselines/reference/baseConstraintOfDecorator.symbols index 9048d7ed568..0a1dad239af 100644 --- a/tests/baselines/reference/baseConstraintOfDecorator.symbols +++ b/tests/baselines/reference/baseConstraintOfDecorator.symbols @@ -51,6 +51,7 @@ export function classExtender2 MyCl >args : Symbol(args, Decl(baseConstraintOfDecorator.ts, 12, 20)) super(...args); +>super : Symbol(TFunction, Decl(baseConstraintOfDecorator.ts, 10, 31)) >args : Symbol(args, Decl(baseConstraintOfDecorator.ts, 12, 20)) _instanceModifier(this, args); diff --git a/tests/baselines/reference/baseConstraintOfDecorator.types b/tests/baselines/reference/baseConstraintOfDecorator.types index a5a277c5d2a..78c77ee78a2 100644 --- a/tests/baselines/reference/baseConstraintOfDecorator.types +++ b/tests/baselines/reference/baseConstraintOfDecorator.types @@ -42,16 +42,16 @@ export function classExtender2 MyCl >args : any[] return class decoratorFunc extends superClass { ->class decoratorFunc extends superClass { constructor(...args: any[]) { super(...args); _instanceModifier(this, args); } } : typeof decoratorFunc ->decoratorFunc : typeof decoratorFunc ->superClass : TFunction +>class decoratorFunc extends superClass { constructor(...args: any[]) { super(...args); _instanceModifier(this, args); } } : { new (...args: any[]): decoratorFunc; prototype: classExtender2.decoratorFunc; } & TFunction +>decoratorFunc : { new (...args: any[]): decoratorFunc; prototype: classExtender2.decoratorFunc; } & TFunction +>superClass : MyClass constructor(...args: any[]) { >args : any[] super(...args); >super(...args) : void ->super : any +>super : TFunction >...args : any >args : any[] diff --git a/tests/baselines/reference/bigintWithLib.errors.txt b/tests/baselines/reference/bigintWithLib.errors.txt index b4c9f65cf9c..fb54c2a530b 100644 --- a/tests/baselines/reference/bigintWithLib.errors.txt +++ b/tests/baselines/reference/bigintWithLib.errors.txt @@ -4,15 +4,11 @@ tests/cases/compiler/bigintWithLib.ts(16,33): error TS2769: No overload matches Argument of type 'number[]' is not assignable to parameter of type 'number'. Overload 2 of 3, '(array: Iterable): BigInt64Array', gave the following error. Argument of type 'number[]' is not assignable to parameter of type 'Iterable'. - Types of property '[Symbol.iterator]' are incompatible. - Type '() => IterableIterator' is not assignable to type '() => Iterator'. - Type 'IterableIterator' is not assignable to type 'Iterator'. - Types of property 'next' are incompatible. - Type '(...args: [] | [undefined]) => IteratorResult' is not assignable to type '(...args: [] | [undefined]) => IteratorResult'. - Type 'IteratorResult' is not assignable to type 'IteratorResult'. - Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. - Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. - Type 'number' is not assignable to type 'bigint'. + The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types. + Type 'IteratorResult' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. + Type 'number' is not assignable to type 'bigint'. Overload 3 of 3, '(buffer: ArrayBuffer | SharedArrayBuffer, byteOffset?: number, length?: number): BigInt64Array', gave the following error. Argument of type 'number[]' is not assignable to parameter of type 'ArrayBuffer | SharedArrayBuffer'. Type 'number[]' is missing the following properties from type 'SharedArrayBuffer': byteLength, [Symbol.species], [Symbol.toStringTag] @@ -55,15 +51,11 @@ tests/cases/compiler/bigintWithLib.ts(43,26): error TS2345: Argument of type '12 !!! error TS2769: Argument of type 'number[]' is not assignable to parameter of type 'number'. !!! error TS2769: Overload 2 of 3, '(array: Iterable): BigInt64Array', gave the following error. !!! error TS2769: Argument of type 'number[]' is not assignable to parameter of type 'Iterable'. -!!! error TS2769: Types of property '[Symbol.iterator]' are incompatible. -!!! error TS2769: Type '() => IterableIterator' is not assignable to type '() => Iterator'. -!!! error TS2769: Type 'IterableIterator' is not assignable to type 'Iterator'. -!!! error TS2769: Types of property 'next' are incompatible. -!!! error TS2769: Type '(...args: [] | [undefined]) => IteratorResult' is not assignable to type '(...args: [] | [undefined]) => IteratorResult'. -!!! error TS2769: Type 'IteratorResult' is not assignable to type 'IteratorResult'. -!!! error TS2769: Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. -!!! error TS2769: Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. -!!! error TS2769: Type 'number' is not assignable to type 'bigint'. +!!! error TS2769: The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types. +!!! error TS2769: Type 'IteratorResult' is not assignable to type 'IteratorResult'. +!!! error TS2769: Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. +!!! error TS2769: Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. +!!! error TS2769: Type 'number' is not assignable to type 'bigint'. !!! error TS2769: Overload 3 of 3, '(buffer: ArrayBuffer | SharedArrayBuffer, byteOffset?: number, length?: number): BigInt64Array', gave the following error. !!! error TS2769: Argument of type 'number[]' is not assignable to parameter of type 'ArrayBuffer | SharedArrayBuffer'. !!! error TS2769: Type 'number[]' is missing the following properties from type 'SharedArrayBuffer': byteLength, [Symbol.species], [Symbol.toStringTag] diff --git a/tests/baselines/reference/booleanAssignment.errors.txt b/tests/baselines/reference/booleanAssignment.errors.txt index fc25fd4007f..8a928c57404 100644 --- a/tests/baselines/reference/booleanAssignment.errors.txt +++ b/tests/baselines/reference/booleanAssignment.errors.txt @@ -1,9 +1,8 @@ tests/cases/compiler/booleanAssignment.ts(2,1): error TS2322: Type '1' is not assignable to type 'Boolean'. tests/cases/compiler/booleanAssignment.ts(3,1): error TS2322: Type '"a"' is not assignable to type 'Boolean'. tests/cases/compiler/booleanAssignment.ts(4,1): error TS2322: Type '{}' is not assignable to type 'Boolean'. - Types of property 'valueOf' are incompatible. - Type '() => Object' is not assignable to type '() => boolean'. - Type 'Object' is not assignable to type 'boolean'. + The types returned by 'valueOf()' are incompatible between these types. + Type 'Object' is not assignable to type 'boolean'. ==== tests/cases/compiler/booleanAssignment.ts (3 errors) ==== @@ -17,9 +16,8 @@ tests/cases/compiler/booleanAssignment.ts(4,1): error TS2322: Type '{}' is not a b = {}; // Error ~ !!! error TS2322: Type '{}' is not assignable to type 'Boolean'. -!!! error TS2322: Types of property 'valueOf' are incompatible. -!!! error TS2322: Type '() => Object' is not assignable to type '() => boolean'. -!!! error TS2322: Type 'Object' is not assignable to type 'boolean'. +!!! error TS2322: The types returned by 'valueOf()' are incompatible between these types. +!!! error TS2322: Type 'Object' is not assignable to type 'boolean'. var o = {}; o = b; // OK diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance.errors.txt b/tests/baselines/reference/callSignatureAssignabilityInInheritance.errors.txt index 2ca3bb1aaf0..43589e94370 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance.errors.txt +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance.errors.txt @@ -1,12 +1,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance.ts(57,15): error TS2430: Interface 'I2' incorrectly extends interface 'Base2'. - Types of property 'a' are incompatible. - Type '(x: number) => string' is not assignable to type '(x: number) => number'. - Type 'string' is not assignable to type 'number'. + The types returned by 'a(...)' are incompatible between these types. + Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance.ts(63,15): error TS2430: Interface 'I3' incorrectly extends interface 'Base2'. - Types of property 'a2' are incompatible. - Type '(x: T) => string' is not assignable to type '(x: T) => T'. - Type 'string' is not assignable to type 'T'. - 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + The types returned by 'a2(...)' are incompatible between these types. + Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance.ts (2 errors) ==== @@ -69,9 +67,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign interface I2 extends Base2 { ~~ !!! error TS2430: Interface 'I2' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'a' are incompatible. -!!! error TS2430: Type '(x: number) => string' is not assignable to type '(x: number) => number'. -!!! error TS2430: Type 'string' is not assignable to type 'number'. +!!! error TS2430: The types returned by 'a(...)' are incompatible between these types. +!!! error TS2430: Type 'string' is not assignable to type 'number'. // N's a: (x: number) => string; // error because base returns non-void; } @@ -80,10 +77,9 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign interface I3 extends Base2 { ~~ !!! error TS2430: Interface 'I3' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'a2' are incompatible. -!!! error TS2430: Type '(x: T) => string' is not assignable to type '(x: T) => T'. -!!! error TS2430: Type 'string' is not assignable to type 'T'. -!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: The types returned by 'a2(...)' are incompatible between these types. +!!! error TS2430: Type 'string' is not assignable to type 'T'. +!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. // N's a2: (x: T) => string; // error because base returns non-void; } diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt index 671c09b3d79..287875d44da 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt @@ -27,16 +27,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign Types of property 'a' are incompatible. Type 'string' is not assignable to type 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts(100,19): error TS2430: Interface 'I6' incorrectly extends interface 'B'. - Types of property 'a2' are incompatible. - Type '(x: T) => string[]' is not assignable to type '(x: T) => T[]'. - Type 'string[]' is not assignable to type 'T[]'. - Type 'string' is not assignable to type 'T'. - 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + The types returned by 'a2(...)' are incompatible between these types. + Type 'string[]' is not assignable to type 'T[]'. + Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts(109,19): error TS2430: Interface 'I7' incorrectly extends interface 'C'. - Types of property 'a2' are incompatible. - Type '(x: T) => T[]' is not assignable to type '(x: T) => string[]'. - Type 'T[]' is not assignable to type 'string[]'. - Type 'T' is not assignable to type 'string'. + The types returned by 'a2(...)' are incompatible between these types. + Type 'T[]' is not assignable to type 'string[]'. + Type 'T' is not assignable to type 'string'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts (6 errors) ==== @@ -174,11 +172,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign interface I6 extends B { ~~ !!! error TS2430: Interface 'I6' incorrectly extends interface 'B'. -!!! error TS2430: Types of property 'a2' are incompatible. -!!! error TS2430: Type '(x: T) => string[]' is not assignable to type '(x: T) => T[]'. -!!! error TS2430: Type 'string[]' is not assignable to type 'T[]'. -!!! error TS2430: Type 'string' is not assignable to type 'T'. -!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: The types returned by 'a2(...)' are incompatible between these types. +!!! error TS2430: Type 'string[]' is not assignable to type 'T[]'. +!!! error TS2430: Type 'string' is not assignable to type 'T'. +!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: (x: T) => string[]; // error } @@ -190,10 +187,9 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign interface I7 extends C { ~~ !!! error TS2430: Interface 'I7' incorrectly extends interface 'C'. -!!! error TS2430: Types of property 'a2' are incompatible. -!!! error TS2430: Type '(x: T) => T[]' is not assignable to type '(x: T) => string[]'. -!!! error TS2430: Type 'T[]' is not assignable to type 'string[]'. -!!! error TS2430: Type 'T' is not assignable to type 'string'. +!!! error TS2430: The types returned by 'a2(...)' are incompatible between these types. +!!! error TS2430: Type 'T[]' is not assignable to type 'string[]'. +!!! error TS2430: Type 'T' is not assignable to type 'string'. a2: (x: T) => T[]; // error } } diff --git a/tests/baselines/reference/checkJsxChildrenCanBeTupleType.errors.txt b/tests/baselines/reference/checkJsxChildrenCanBeTupleType.errors.txt index aeaeb56ea75..0780f4e92c1 100644 --- a/tests/baselines/reference/checkJsxChildrenCanBeTupleType.errors.txt +++ b/tests/baselines/reference/checkJsxChildrenCanBeTupleType.errors.txt @@ -1,10 +1,8 @@ tests/cases/conformance/jsx/checkJsxChildrenCanBeTupleType.tsx(17,18): error TS2769: No overload matches this call. Overload 1 of 2, '(props: Readonly): ResizablePanel', gave the following error. Type '{ children: [Element, Element, Element]; }' is not assignable to type 'Readonly'. - Types of property 'children' are incompatible. - Type '[Element, Element, Element]' is not assignable to type '[ReactNode, ReactNode]'. - Types of property 'length' are incompatible. - Type '3' is not assignable to type '2'. + The types of 'children.length' are incompatible between these types. + Type '3' is not assignable to type '2'. Overload 2 of 2, '(props: ResizablePanelProps, context?: any): ResizablePanel', gave the following error. Type '{ children: [Element, Element, Element]; }' is not assignable to type 'Readonly'. Types of property 'children' are incompatible. @@ -33,10 +31,8 @@ tests/cases/conformance/jsx/checkJsxChildrenCanBeTupleType.tsx(17,18): error TS2 !!! error TS2769: No overload matches this call. !!! error TS2769: Overload 1 of 2, '(props: Readonly): ResizablePanel', gave the following error. !!! error TS2769: Type '{ children: [Element, Element, Element]; }' is not assignable to type 'Readonly'. -!!! error TS2769: Types of property 'children' are incompatible. -!!! error TS2769: Type '[Element, Element, Element]' is not assignable to type '[ReactNode, ReactNode]'. -!!! error TS2769: Types of property 'length' are incompatible. -!!! error TS2769: Type '3' is not assignable to type '2'. +!!! error TS2769: The types of 'children.length' are incompatible between these types. +!!! error TS2769: Type '3' is not assignable to type '2'. !!! error TS2769: Overload 2 of 2, '(props: ResizablePanelProps, context?: any): ResizablePanel', gave the following error. !!! error TS2769: Type '{ children: [Element, Element, Element]; }' is not assignable to type 'Readonly'. !!! error TS2769: Types of property 'children' are incompatible. diff --git a/tests/baselines/reference/checkJsxChildrenProperty15.errors.txt b/tests/baselines/reference/checkJsxChildrenProperty15.errors.txt index 605a293ffaa..d0be275765f 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty15.errors.txt +++ b/tests/baselines/reference/checkJsxChildrenProperty15.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsx/file.tsx(10,13): error TS2322: Type '{ children: Element; }' is not assignable to type 'IntrinsicAttributes'. +tests/cases/conformance/jsx/file.tsx(10,17): error TS2322: Type '{ children: Element; }' is not assignable to type 'IntrinsicAttributes'. Property 'children' does not exist on type 'IntrinsicAttributes'. tests/cases/conformance/jsx/file.tsx(11,13): error TS2322: Type '{ children: Element; key: string; }' is not assignable to type 'IntrinsicAttributes'. Property 'children' does not exist on type 'IntrinsicAttributes'. @@ -17,7 +17,7 @@ tests/cases/conformance/jsx/file.tsx(12,13): error TS2322: Type '{ children: Ele // Not OK (excess children) const k3 = } />; - ~~~ + ~~~~~~~~ !!! error TS2322: Type '{ children: Element; }' is not assignable to type 'IntrinsicAttributes'. !!! error TS2322: Property 'children' does not exist on type 'IntrinsicAttributes'. const k4 =
; diff --git a/tests/baselines/reference/checkJsxChildrenProperty3.types b/tests/baselines/reference/checkJsxChildrenProperty3.types index f2ed3dc8fd0..2d4380a1975 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty3.types +++ b/tests/baselines/reference/checkJsxChildrenProperty3.types @@ -31,11 +31,11 @@ class FetchUser extends React.Component { ? this.props.children(this.state.result) >this.props.children(this.state.result) : JSX.Element ->this.props.children : ((user: IUser) => JSX.Element) | (((user: IUser) => JSX.Element) & string) | (((user: IUser) => JSX.Element) & number) | (((user: IUser) => JSX.Element) & false) | (((user: IUser) => JSX.Element) & true) | (((user: IUser) => JSX.Element) & React.ReactElement) | (((user: IUser) => JSX.Element) & (string | number | boolean | any[] | React.ReactElement)[]) +>this.props.children : ((user: IUser) => JSX.Element) | (((user: IUser) => JSX.Element) & string) | (((user: IUser) => JSX.Element) & number) | (((user: IUser) => JSX.Element) & false) | (((user: IUser) => JSX.Element) & true) | (((user: IUser) => JSX.Element) & React.ReactElement) | (((user: IUser) => JSX.Element) & (string | number | boolean | React.ReactElement | any[])[]) >this.props : IFetchUserProps & { children?: React.ReactNode; } >this : this >props : IFetchUserProps & { children?: React.ReactNode; } ->children : ((user: IUser) => JSX.Element) | (((user: IUser) => JSX.Element) & string) | (((user: IUser) => JSX.Element) & number) | (((user: IUser) => JSX.Element) & false) | (((user: IUser) => JSX.Element) & true) | (((user: IUser) => JSX.Element) & React.ReactElement) | (((user: IUser) => JSX.Element) & (string | number | boolean | any[] | React.ReactElement)[]) +>children : ((user: IUser) => JSX.Element) | (((user: IUser) => JSX.Element) & string) | (((user: IUser) => JSX.Element) & number) | (((user: IUser) => JSX.Element) & false) | (((user: IUser) => JSX.Element) & true) | (((user: IUser) => JSX.Element) & React.ReactElement) | (((user: IUser) => JSX.Element) & (string | number | boolean | React.ReactElement | any[])[]) >this.state.result : any >this.state : any >this : this diff --git a/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt b/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt index 34bd2189964..40eb1d77677 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt +++ b/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/jsx/file.tsx(24,28): error TS2551: Property 'NAme' does not exist on type 'IUser'. Did you mean 'Name'? -tests/cases/conformance/jsx/file.tsx(36,15): error TS2322: Type '(user: IUser) => Element' is not assignable to type 'string | number | boolean | any[] | ReactElement'. - Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement': type, props -tests/cases/conformance/jsx/file.tsx(39,15): error TS2322: Type '(user: IUser) => Element' is not assignable to type 'string | number | boolean | any[] | ReactElement'. - Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement': type, props +tests/cases/conformance/jsx/file.tsx(36,15): error TS2322: Type '(user: IUser) => Element' is not assignable to type 'string | number | boolean | ReactElement | any[]'. + Type '(user: IUser) => Element' is missing the following properties from type 'any[]': push, pop, concat, join, and 15 more. +tests/cases/conformance/jsx/file.tsx(39,15): error TS2322: Type '(user: IUser) => Element' is not assignable to type 'string | number | boolean | ReactElement | any[]'. + Type '(user: IUser) => Element' is missing the following properties from type 'any[]': push, pop, concat, join, and 15 more. ==== tests/cases/conformance/jsx/file.tsx (3 errors) ==== @@ -50,8 +50,8 @@ tests/cases/conformance/jsx/file.tsx(39,15): error TS2322: Type '(user: IUser) = ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) } ~~~~~~~~~~~~~ -!!! error TS2322: Type '(user: IUser) => Element' is not assignable to type 'string | number | boolean | any[] | ReactElement'. -!!! error TS2322: Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement': type, props +!!! error TS2322: Type '(user: IUser) => Element' is not assignable to type 'string | number | boolean | ReactElement | any[]'. +!!! error TS2322: Type '(user: IUser) => Element' is missing the following properties from type 'any[]': push, pop, concat, join, and 15 more. !!! related TS6212 tests/cases/conformance/jsx/file.tsx:36:15: Did you mean to call this expression? { user => ( ~~~~~~~~~ @@ -59,8 +59,8 @@ tests/cases/conformance/jsx/file.tsx(39,15): error TS2322: Type '(user: IUser) = ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) } ~~~~~~~~~~~~~ -!!! error TS2322: Type '(user: IUser) => Element' is not assignable to type 'string | number | boolean | any[] | ReactElement'. -!!! error TS2322: Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement': type, props +!!! error TS2322: Type '(user: IUser) => Element' is not assignable to type 'string | number | boolean | ReactElement | any[]'. +!!! error TS2322: Type '(user: IUser) => Element' is missing the following properties from type 'any[]': push, pop, concat, join, and 15 more. !!! related TS6212 tests/cases/conformance/jsx/file.tsx:39:15: Did you mean to call this expression? ); diff --git a/tests/baselines/reference/checkJsxChildrenProperty4.types b/tests/baselines/reference/checkJsxChildrenProperty4.types index 067e8f2611a..4f753cf9f3b 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty4.types +++ b/tests/baselines/reference/checkJsxChildrenProperty4.types @@ -31,11 +31,11 @@ class FetchUser extends React.Component { ? this.props.children(this.state.result) >this.props.children(this.state.result) : JSX.Element ->this.props.children : ((user: IUser) => JSX.Element) | (((user: IUser) => JSX.Element) & string) | (((user: IUser) => JSX.Element) & number) | (((user: IUser) => JSX.Element) & false) | (((user: IUser) => JSX.Element) & true) | (((user: IUser) => JSX.Element) & React.ReactElement) | (((user: IUser) => JSX.Element) & (string | number | boolean | any[] | React.ReactElement)[]) +>this.props.children : ((user: IUser) => JSX.Element) | (((user: IUser) => JSX.Element) & string) | (((user: IUser) => JSX.Element) & number) | (((user: IUser) => JSX.Element) & false) | (((user: IUser) => JSX.Element) & true) | (((user: IUser) => JSX.Element) & React.ReactElement) | (((user: IUser) => JSX.Element) & (string | number | boolean | React.ReactElement | any[])[]) >this.props : IFetchUserProps & { children?: React.ReactNode; } >this : this >props : IFetchUserProps & { children?: React.ReactNode; } ->children : ((user: IUser) => JSX.Element) | (((user: IUser) => JSX.Element) & string) | (((user: IUser) => JSX.Element) & number) | (((user: IUser) => JSX.Element) & false) | (((user: IUser) => JSX.Element) & true) | (((user: IUser) => JSX.Element) & React.ReactElement) | (((user: IUser) => JSX.Element) & (string | number | boolean | any[] | React.ReactElement)[]) +>children : ((user: IUser) => JSX.Element) | (((user: IUser) => JSX.Element) & string) | (((user: IUser) => JSX.Element) & number) | (((user: IUser) => JSX.Element) & false) | (((user: IUser) => JSX.Element) & true) | (((user: IUser) => JSX.Element) & React.ReactElement) | (((user: IUser) => JSX.Element) & (string | number | boolean | React.ReactElement | any[])[]) >this.state.result : any >this.state : any >this : this diff --git a/tests/baselines/reference/complexRecursiveCollections.errors.txt b/tests/baselines/reference/complexRecursiveCollections.errors.txt index 27bb24bc5cc..cd88e596fd1 100644 --- a/tests/baselines/reference/complexRecursiveCollections.errors.txt +++ b/tests/baselines/reference/complexRecursiveCollections.errors.txt @@ -1,18 +1,15 @@ tests/cases/compiler/immutable.ts(341,22): error TS2430: Interface 'Keyed' incorrectly extends interface 'Collection'. - Types of property 'toSeq' are incompatible. - Type '() => Keyed' is not assignable to type '() => this'. - Type 'Keyed' is not assignable to type 'this'. - 'Keyed' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Keyed'. + The types returned by 'toSeq()' are incompatible between these types. + Type 'Keyed' is not assignable to type 'this'. + 'Keyed' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Keyed'. tests/cases/compiler/immutable.ts(359,22): error TS2430: Interface 'Indexed' incorrectly extends interface 'Collection'. - Types of property 'toSeq' are incompatible. - Type '() => Indexed' is not assignable to type '() => this'. - Type 'Indexed' is not assignable to type 'this'. - 'Indexed' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Indexed'. + The types returned by 'toSeq()' are incompatible between these types. + Type 'Indexed' is not assignable to type 'this'. + 'Indexed' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Indexed'. tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set' incorrectly extends interface 'Collection'. - Types of property 'toSeq' are incompatible. - Type '() => Set' is not assignable to type '() => this'. - Type 'Set' is not assignable to type 'this'. - 'Set' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Set'. + The types returned by 'toSeq()' are incompatible between these types. + Type 'Set' is not assignable to type 'this'. + 'Set' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Set'. ==== tests/cases/compiler/complex.ts (0 errors) ==== @@ -380,10 +377,9 @@ tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set' inco export interface Keyed extends Collection { ~~~~~ !!! error TS2430: Interface 'Keyed' incorrectly extends interface 'Collection'. -!!! error TS2430: Types of property 'toSeq' are incompatible. -!!! error TS2430: Type '() => Keyed' is not assignable to type '() => this'. -!!! error TS2430: Type 'Keyed' is not assignable to type 'this'. -!!! error TS2430: 'Keyed' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Keyed'. +!!! error TS2430: The types returned by 'toSeq()' are incompatible between these types. +!!! error TS2430: Type 'Keyed' is not assignable to type 'this'. +!!! error TS2430: 'Keyed' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Keyed'. toJS(): Object; toJSON(): { [key: string]: V }; toSeq(): Seq.Keyed; @@ -404,10 +400,9 @@ tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set' inco export interface Indexed extends Collection { ~~~~~~~ !!! error TS2430: Interface 'Indexed' incorrectly extends interface 'Collection'. -!!! error TS2430: Types of property 'toSeq' are incompatible. -!!! error TS2430: Type '() => Indexed' is not assignable to type '() => this'. -!!! error TS2430: Type 'Indexed' is not assignable to type 'this'. -!!! error TS2430: 'Indexed' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Indexed'. +!!! error TS2430: The types returned by 'toSeq()' are incompatible between these types. +!!! error TS2430: Type 'Indexed' is not assignable to type 'this'. +!!! error TS2430: 'Indexed' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Indexed'. toJS(): Array; toJSON(): Array; // Reading values @@ -442,10 +437,9 @@ tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set' inco export interface Set extends Collection { ~~~ !!! error TS2430: Interface 'Set' incorrectly extends interface 'Collection'. -!!! error TS2430: Types of property 'toSeq' are incompatible. -!!! error TS2430: Type '() => Set' is not assignable to type '() => this'. -!!! error TS2430: Type 'Set' is not assignable to type 'this'. -!!! error TS2430: 'Set' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Set'. +!!! error TS2430: The types returned by 'toSeq()' are incompatible between these types. +!!! error TS2430: Type 'Set' is not assignable to type 'this'. +!!! error TS2430: 'Set' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Set'. toJS(): Array; toJSON(): Array; toSeq(): Seq.Set; diff --git a/tests/baselines/reference/complicatedIndexesOfIntersectionsAreInferencable.types b/tests/baselines/reference/complicatedIndexesOfIntersectionsAreInferencable.types index 64511cb9df2..55d6368e292 100644 --- a/tests/baselines/reference/complicatedIndexesOfIntersectionsAreInferencable.types +++ b/tests/baselines/reference/complicatedIndexesOfIntersectionsAreInferencable.types @@ -12,10 +12,10 @@ interface FormikConfig { } declare function Func( ->Func : (x: string extends "validate" | "initialValues" | keyof ExtraProps ? Readonly & ExtraProps> : Pick & ExtraProps>, "validate" | "initialValues" | Exclude> & Partial & ExtraProps>, "validateOnChange" | Extract>>) => void +>Func : (x: string extends keyof ExtraProps | "validate" | "initialValues" ? Readonly & ExtraProps> : Pick & ExtraProps>, Exclude | "validate" | "initialValues"> & Partial & ExtraProps>, "validateOnChange" | Extract>>) => void x: (string extends "validate" | "initialValues" | keyof ExtraProps ->x : string extends "validate" | "initialValues" | keyof ExtraProps ? Readonly & ExtraProps> : Pick & ExtraProps>, "validate" | "initialValues" | Exclude> & Partial & ExtraProps>, "validateOnChange" | Extract>> +>x : string extends keyof ExtraProps | "validate" | "initialValues" ? Readonly & ExtraProps> : Pick & ExtraProps>, Exclude | "validate" | "initialValues"> & Partial & ExtraProps>, "validateOnChange" | Extract>> ? Readonly & ExtraProps> : Pick & ExtraProps>, "validate" | "initialValues" | Exclude> @@ -24,7 +24,7 @@ declare function Func( Func({ >Func({ initialValues: { foo: "" }, validate: props => { props.foo; }}) : void ->Func : (x: string extends "validate" | "initialValues" | keyof ExtraProps ? Readonly & ExtraProps> : Pick & ExtraProps>, "validate" | "initialValues" | Exclude> & Partial & ExtraProps>, "validateOnChange" | Extract>>) => void +>Func : (x: string extends keyof ExtraProps | "validate" | "initialValues" ? Readonly & ExtraProps> : Pick & ExtraProps>, Exclude | "validate" | "initialValues"> & Partial & ExtraProps>, "validateOnChange" | Extract>>) => void >{ initialValues: { foo: "" }, validate: props => { props.foo; }} : { initialValues: { foo: string; }; validate: (props: { foo: string; }) => void; } initialValues: { diff --git a/tests/baselines/reference/conditionalTypes1.types b/tests/baselines/reference/conditionalTypes1.types index 234fc071d74..2d5af28ca5e 100644 --- a/tests/baselines/reference/conditionalTypes1.types +++ b/tests/baselines/reference/conditionalTypes1.types @@ -494,7 +494,7 @@ function f21(x: T, y: ZeroOf) { } type T35 = T[]; ->T35 : T[] +>T35 : T35 >a : string >b : number diff --git a/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.types b/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.types index b3f5a0e9f91..1170aa71c48 100644 --- a/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.types +++ b/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.types @@ -6,7 +6,7 @@ interface Map { } export type ImmutableTypes = IImmutableMap; ->ImmutableTypes : IImmutableMap +>ImmutableTypes : ImmutableTypes export type ImmutableModel = { [K in keyof T]: T[K] extends ImmutableTypes ? T[K] : never }; >ImmutableModel : ImmutableModel @@ -19,7 +19,7 @@ export interface IImmutableMap> extends Map; ->ImmutableTypes2 : IImmutableMap2 +>ImmutableTypes2 : ImmutableTypes2 type isImmutableType = [T] extends [ImmutableTypes2] ? T : never; >isImmutableType : isImmutableType diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance.errors.txt b/tests/baselines/reference/constructSignatureAssignabilityInInheritance.errors.txt index e326d163c8c..1cc019746ba 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance.errors.txt +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance.errors.txt @@ -1,12 +1,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance.ts(61,15): error TS2430: Interface 'I2' incorrectly extends interface 'Base2'. - Types of property 'a' are incompatible. - Type 'new (x: number) => string' is not assignable to type 'new (x: number) => number'. - Type 'string' is not assignable to type 'number'. + The types returned by 'new a(...)' are incompatible between these types. + Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance.ts(67,15): error TS2430: Interface 'I3' incorrectly extends interface 'Base2'. - Types of property 'a2' are incompatible. - Type 'new (x: T) => string' is not assignable to type 'new (x: T) => T'. - Type 'string' is not assignable to type 'T'. - 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + The types returned by 'new a2(...)' are incompatible between these types. + Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance.ts (2 errors) ==== @@ -73,9 +71,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc interface I2 extends Base2 { ~~ !!! error TS2430: Interface 'I2' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'a' are incompatible. -!!! error TS2430: Type 'new (x: number) => string' is not assignable to type 'new (x: number) => number'. -!!! error TS2430: Type 'string' is not assignable to type 'number'. +!!! error TS2430: The types returned by 'new a(...)' are incompatible between these types. +!!! error TS2430: Type 'string' is not assignable to type 'number'. // N's a: new (x: number) => string; // error because base returns non-void; } @@ -84,10 +81,9 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc interface I3 extends Base2 { ~~ !!! error TS2430: Interface 'I3' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'a2' are incompatible. -!!! error TS2430: Type 'new (x: T) => string' is not assignable to type 'new (x: T) => T'. -!!! error TS2430: Type 'string' is not assignable to type 'T'. -!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: The types returned by 'new a2(...)' are incompatible between these types. +!!! error TS2430: Type 'string' is not assignable to type 'T'. +!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. // N's a2: new (x: T) => string; // error because base returns non-void; } diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt index 59d8105c59c..d4c9e808200 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt @@ -27,16 +27,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc Types of property 'a' are incompatible. Type 'string' is not assignable to type 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance3.ts(86,19): error TS2430: Interface 'I6' incorrectly extends interface 'B'. - Types of property 'a2' are incompatible. - Type 'new (x: T) => string[]' is not assignable to type 'new (x: T) => T[]'. - Type 'string[]' is not assignable to type 'T[]'. - Type 'string' is not assignable to type 'T'. - 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + The types returned by 'new a2(...)' are incompatible between these types. + Type 'string[]' is not assignable to type 'T[]'. + Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance3.ts(95,19): error TS2430: Interface 'I7' incorrectly extends interface 'C'. - Types of property 'a2' are incompatible. - Type 'new (x: T) => T[]' is not assignable to type 'new (x: T) => string[]'. - Type 'T[]' is not assignable to type 'string[]'. - Type 'T' is not assignable to type 'string'. + The types returned by 'new a2(...)' are incompatible between these types. + Type 'T[]' is not assignable to type 'string[]'. + Type 'T' is not assignable to type 'string'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance3.ts (6 errors) ==== @@ -160,11 +158,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc interface I6 extends B { ~~ !!! error TS2430: Interface 'I6' incorrectly extends interface 'B'. -!!! error TS2430: Types of property 'a2' are incompatible. -!!! error TS2430: Type 'new (x: T) => string[]' is not assignable to type 'new (x: T) => T[]'. -!!! error TS2430: Type 'string[]' is not assignable to type 'T[]'. -!!! error TS2430: Type 'string' is not assignable to type 'T'. -!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: The types returned by 'new a2(...)' are incompatible between these types. +!!! error TS2430: Type 'string[]' is not assignable to type 'T[]'. +!!! error TS2430: Type 'string' is not assignable to type 'T'. +!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: new (x: T) => string[]; // error } @@ -176,10 +173,9 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc interface I7 extends C { ~~ !!! error TS2430: Interface 'I7' incorrectly extends interface 'C'. -!!! error TS2430: Types of property 'a2' are incompatible. -!!! error TS2430: Type 'new (x: T) => T[]' is not assignable to type 'new (x: T) => string[]'. -!!! error TS2430: Type 'T[]' is not assignable to type 'string[]'. -!!! error TS2430: Type 'T' is not assignable to type 'string'. +!!! error TS2430: The types returned by 'new a2(...)' are incompatible between these types. +!!! error TS2430: Type 'T[]' is not assignable to type 'string[]'. +!!! error TS2430: Type 'T' is not assignable to type 'string'. a2: new (x: T) => T[]; // error } diff --git a/tests/baselines/reference/contextualTypingOfOptionalMembers.types b/tests/baselines/reference/contextualTypingOfOptionalMembers.types index f4a9e23190d..8978cb86e07 100644 --- a/tests/baselines/reference/contextualTypingOfOptionalMembers.types +++ b/tests/baselines/reference/contextualTypingOfOptionalMembers.types @@ -124,17 +124,17 @@ app2({ type ActionsArray = ((state: State) => State)[]; ->ActionsArray : ((state: State) => State)[] +>ActionsArray : ActionsArray >state : State declare function app3>(obj: Options): void; ->app3 : State)[]>(obj: Options) => void +>app3 : >(obj: Options) => void >obj : Options app3({ >app3({ state: 100, actions: [ s => s // Should be typed number => number ], view: (s, a) => undefined as any,}) : void ->app3 : State)[]>(obj: Options) => void ->{ state: 100, actions: [ s => s // Should be typed number => number ], view: (s, a) => undefined as any,} : { state: number; actions: ((s: number) => number)[]; view: (s: number, a: ((state: number) => number)[]) => any; } +>app3 : >(obj: Options) => void +>{ state: 100, actions: [ s => s // Should be typed number => number ], view: (s, a) => undefined as any,} : { state: number; actions: ((s: number) => number)[]; view: (s: number, a: ActionsArray) => any; } state: 100, >state : number @@ -151,10 +151,10 @@ app3({ ], view: (s, a) => undefined as any, ->view : (s: number, a: ((state: number) => number)[]) => any ->(s, a) => undefined as any : (s: number, a: ((state: number) => number)[]) => any +>view : (s: number, a: ActionsArray) => any +>(s, a) => undefined as any : (s: number, a: ActionsArray) => any >s : number ->a : ((state: number) => number)[] +>a : ActionsArray >undefined as any : any >undefined : undefined diff --git a/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes02.errors.txt b/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes02.errors.txt index ff2ec7e5106..b66975fdb73 100644 --- a/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes02.errors.txt +++ b/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes02.errors.txt @@ -1,34 +1,34 @@ -tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(27,13): error TS2769: No overload matches this call. +tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(27,64): error TS2769: No overload matches this call. Overload 1 of 2, '(buttonProps: ButtonProps): Element', gave the following error. Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'. Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'. Overload 2 of 2, '(linkProps: LinkProps): Element', gave the following error. Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. -tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(28,13): error TS2769: No overload matches this call. +tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(28,12): error TS2769: No overload matches this call. Overload 1 of 2, '(buttonProps: ButtonProps): Element', gave the following error. Type '{ onClick: (k: "left" | "right") => void; extra: true; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'. Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'. Overload 2 of 2, '(linkProps: LinkProps): Element', gave the following error. Type '{ onClick: (k: "left" | "right") => void; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. Property 'onClick' does not exist on type 'IntrinsicAttributes & LinkProps'. -tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(29,13): error TS2769: No overload matches this call. +tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(29,43): error TS2769: No overload matches this call. Overload 1 of 2, '(buttonProps: ButtonProps): Element', gave the following error. Type '{ extra: true; goTo: string; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'. Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'. Overload 2 of 2, '(linkProps: LinkProps): Element', gave the following error. Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. -tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(30,13): error TS2769: No overload matches this call. +tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(30,12): error TS2769: No overload matches this call. Overload 1 of 2, '(buttonProps: ButtonProps): Element', gave the following error. Type '{ goTo: string; extra: true; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'. Property 'goTo' does not exist on type 'IntrinsicAttributes & ButtonProps'. Overload 2 of 2, '(linkProps: LinkProps): Element', gave the following error. Type '{ goTo: "home"; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. -tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(33,13): error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'. +tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(33,65): error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'. Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'. -tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,13): error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. +tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,44): error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. @@ -60,7 +60,7 @@ tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,13): err } const b0 = {console.log(k)}}} extra />; // k has type "left" | "right" - ~~~~~~~~~~ + ~~~~~ !!! error TS2769: No overload matches this call. !!! error TS2769: Overload 1 of 2, '(buttonProps: ButtonProps): Element', gave the following error. !!! error TS2769: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'. @@ -69,7 +69,7 @@ tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,13): err !!! error TS2769: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. !!! error TS2769: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. const b2 = {console.log(k)}} extra />; // k has type "left" | "right" - ~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2769: No overload matches this call. !!! error TS2769: Overload 1 of 2, '(buttonProps: ButtonProps): Element', gave the following error. !!! error TS2769: Type '{ onClick: (k: "left" | "right") => void; extra: true; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'. @@ -78,7 +78,7 @@ tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,13): err !!! error TS2769: Type '{ onClick: (k: "left" | "right") => void; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. !!! error TS2769: Property 'onClick' does not exist on type 'IntrinsicAttributes & LinkProps'. const b3 = ; // goTo has type"home" | "contact" - ~~~~~~~~~~ + ~~~~~ !!! error TS2769: No overload matches this call. !!! error TS2769: Overload 1 of 2, '(buttonProps: ButtonProps): Element', gave the following error. !!! error TS2769: Type '{ extra: true; goTo: string; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'. @@ -87,7 +87,7 @@ tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,13): err !!! error TS2769: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. !!! error TS2769: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. const b4 = ; // goTo has type "home" | "contact" - ~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2769: No overload matches this call. !!! error TS2769: Overload 1 of 2, '(buttonProps: ButtonProps): Element', gave the following error. !!! error TS2769: Type '{ goTo: string; extra: true; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'. @@ -98,13 +98,13 @@ tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,13): err export function NoOverload(buttonProps: ButtonProps): JSX.Element { return undefined } const c1 = {console.log(k)}}} extra />; // k has type any - ~~~~~~~~~~ + ~~~~~ !!! error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'. !!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'. export function NoOverload1(linkProps: LinkProps): JSX.Element { return undefined } const d1 = ; // goTo has type "home" | "contact" - ~~~~~~~~~~~ + ~~~~~ !!! error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. !!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. \ No newline at end of file diff --git a/tests/baselines/reference/covariantCallbacks.errors.txt b/tests/baselines/reference/covariantCallbacks.errors.txt index 9ee5a9e2fed..401bf454baa 100644 --- a/tests/baselines/reference/covariantCallbacks.errors.txt +++ b/tests/baselines/reference/covariantCallbacks.errors.txt @@ -10,9 +10,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covarian Type 'A' is not assignable to type 'B'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts(43,5): error TS2322: Type 'AList2' is not assignable to type 'BList2'. Types of property 'forEach' are incompatible. - Type '(cb: (item: A) => boolean) => void' is not assignable to type '(cb: (item: A) => void) => void'. - Types of parameters 'cb' and 'cb' are incompatible. - Type 'void' is not assignable to type 'boolean'. + Types of parameters 'cb' and 'cb' are incompatible. + Type 'void' is not assignable to type 'boolean'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts(56,5): error TS2322: Type 'AList3' is not assignable to type 'BList3'. Types of property 'forEach' are incompatible. Type '(cb: (item: A) => void) => void' is not assignable to type '(cb: (item: A, context: any) => void) => void'. @@ -86,9 +85,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covarian ~ !!! error TS2322: Type 'AList2' is not assignable to type 'BList2'. !!! error TS2322: Types of property 'forEach' are incompatible. -!!! error TS2322: Type '(cb: (item: A) => boolean) => void' is not assignable to type '(cb: (item: A) => void) => void'. -!!! error TS2322: Types of parameters 'cb' and 'cb' are incompatible. -!!! error TS2322: Type 'void' is not assignable to type 'boolean'. +!!! error TS2322: Types of parameters 'cb' and 'cb' are incompatible. +!!! error TS2322: Type 'void' is not assignable to type 'boolean'. } interface AList3 { diff --git a/tests/baselines/reference/declarationEmitDestructuringParameterProperties.types b/tests/baselines/reference/declarationEmitDestructuringParameterProperties.types index b7407b0232f..d76fd67f9d6 100644 --- a/tests/baselines/reference/declarationEmitDestructuringParameterProperties.types +++ b/tests/baselines/reference/declarationEmitDestructuringParameterProperties.types @@ -10,7 +10,7 @@ class C1 { } type TupleType1 =[string, number, boolean]; ->TupleType1 : [string, number, boolean] +>TupleType1 : TupleType1 class C2 { >C2 : C2 diff --git a/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.errors.txt b/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.errors.txt deleted file mode 100644 index 1981ce63c92..00000000000 --- a/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.errors.txt +++ /dev/null @@ -1,60 +0,0 @@ -tests/cases/compiler/monorepo/pkg3/src/keys.ts(3,14): error TS2742: The inferred type of 'ADMIN' cannot be named without a reference to '../../pkg2/node_modules/@raymondfeng/pkg1/dist'. This is likely not portable. A type annotation is necessary. - - -==== tests/cases/compiler/monorepo/pkg3/tsconfig.json (0 errors) ==== - { - "compilerOptions": { - "outDir": "dist", - "rootDir": "src", - "target": "es5", - "module": "commonjs", - "strict": true, - "esModuleInterop": true, - "declaration": true - } - } - -==== tests/cases/compiler/monorepo/pkg1/dist/index.d.ts (0 errors) ==== - export * from './types'; -==== tests/cases/compiler/monorepo/pkg1/dist/types.d.ts (0 errors) ==== - export declare type A = { - id: string; - }; - export declare type B = { - id: number; - }; - export declare type IdType = A | B; - export declare class MetadataAccessor { - readonly key: string; - private constructor(); - toString(): string; - static create(key: string): MetadataAccessor; - } -==== tests/cases/compiler/monorepo/pkg1/package.json (0 errors) ==== - { - "name": "@raymondfeng/pkg1", - "version": "1.0.0", - "description": "", - "main": "dist/index.js", - "typings": "dist/index.d.ts" - } -==== tests/cases/compiler/monorepo/pkg2/dist/index.d.ts (0 errors) ==== - export * from './types'; -==== tests/cases/compiler/monorepo/pkg2/dist/types.d.ts (0 errors) ==== - export {MetadataAccessor} from '@raymondfeng/pkg1'; -==== tests/cases/compiler/monorepo/pkg2/package.json (0 errors) ==== - { - "name": "@raymondfeng/pkg2", - "version": "1.0.0", - "description": "", - "main": "dist/index.js", - "typings": "dist/index.d.ts" - } -==== tests/cases/compiler/monorepo/pkg3/src/index.ts (0 errors) ==== - export * from './keys'; -==== tests/cases/compiler/monorepo/pkg3/src/keys.ts (1 errors) ==== - import {MetadataAccessor} from "@raymondfeng/pkg2"; - - export const ADMIN = MetadataAccessor.create('1'); - ~~~~~ -!!! error TS2742: The inferred type of 'ADMIN' cannot be named without a reference to '../../pkg2/node_modules/@raymondfeng/pkg1/dist'. This is likely not portable. A type annotation is necessary. \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.js b/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.js index 2ac5a9fffbd..46b3eded634 100644 --- a/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.js +++ b/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.js @@ -57,5 +57,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./keys")); +//// [keys.d.ts] +import { MetadataAccessor } from "@raymondfeng/pkg2"; +export declare const ADMIN: MetadataAccessor; //// [index.d.ts] export * from './keys'; diff --git a/tests/baselines/reference/declarationsForIndirectTypeAliasReference.js b/tests/baselines/reference/declarationsForIndirectTypeAliasReference.js index 9e2f9ee4039..1563e2571cc 100644 --- a/tests/baselines/reference/declarationsForIndirectTypeAliasReference.js +++ b/tests/baselines/reference/declarationsForIndirectTypeAliasReference.js @@ -61,6 +61,6 @@ declare type StringHash = Hash; interface StringHash2 extends Hash { } //// [a.d.ts] -import { StringHash2 } from "./b"; +import { StringHash, StringHash2 } from "./b"; export { doSome }; -declare function doSome(arg1: string, arg2?: import("./b").Hash, arg3?: StringHash2): void; +declare function doSome(arg1: string, arg2?: StringHash, arg3?: StringHash2): void; diff --git a/tests/baselines/reference/declarationsForIndirectTypeAliasReference.types b/tests/baselines/reference/declarationsForIndirectTypeAliasReference.types index e527a8a3bfa..85ebfca651f 100644 --- a/tests/baselines/reference/declarationsForIndirectTypeAliasReference.types +++ b/tests/baselines/reference/declarationsForIndirectTypeAliasReference.types @@ -15,7 +15,7 @@ interface Hash { } type StringHash = Hash; ->StringHash : Hash +>StringHash : StringHash interface StringHash2 extends Hash {} === tests/cases/compiler/a.ts === @@ -25,11 +25,11 @@ import {StringHash, StringHash2} from "./b"; export { doSome ->doSome : (arg1: string, arg2?: import("tests/cases/compiler/b").Hash, arg3?: StringHash2) => void +>doSome : (arg1: string, arg2?: StringHash, arg3?: StringHash2) => void } const MAP: StringHash = { ->MAP : import("tests/cases/compiler/b").Hash +>MAP : StringHash >{ a: "a"} : { a: string; } a: "a" @@ -49,12 +49,12 @@ const MAP2: StringHash2 = { }; function doSome(arg1: string, ->doSome : (arg1: string, arg2?: import("tests/cases/compiler/b").Hash, arg3?: StringHash2) => void +>doSome : (arg1: string, arg2?: StringHash, arg3?: StringHash2) => void >arg1 : string arg2 = MAP, ->arg2 : import("tests/cases/compiler/b").Hash ->MAP : import("tests/cases/compiler/b").Hash +>arg2 : StringHash +>MAP : StringHash arg3 = MAP2) { >arg3 : StringHash2 diff --git a/tests/baselines/reference/decoratorCallGeneric.errors.txt b/tests/baselines/reference/decoratorCallGeneric.errors.txt index c2e4042743e..495160a191b 100644 --- a/tests/baselines/reference/decoratorCallGeneric.errors.txt +++ b/tests/baselines/reference/decoratorCallGeneric.errors.txt @@ -1,7 +1,6 @@ tests/cases/conformance/decorators/decoratorCallGeneric.ts(7,2): error TS2345: Argument of type 'typeof C' is not assignable to parameter of type 'I'. - Types of property 'm' are incompatible. - Type '() => void' is not assignable to type '() => C'. - Type 'void' is not assignable to type 'C'. + The types returned by 'm()' are incompatible between these types. + Type 'void' is not assignable to type 'C'. ==== tests/cases/conformance/decorators/decoratorCallGeneric.ts (1 errors) ==== @@ -14,9 +13,8 @@ tests/cases/conformance/decorators/decoratorCallGeneric.ts(7,2): error TS2345: A @dec ~~~ !!! error TS2345: Argument of type 'typeof C' is not assignable to parameter of type 'I'. -!!! error TS2345: Types of property 'm' are incompatible. -!!! error TS2345: Type '() => void' is not assignable to type '() => C'. -!!! error TS2345: Type 'void' is not assignable to type 'C'. +!!! error TS2345: The types returned by 'm()' are incompatible between these types. +!!! error TS2345: Type 'void' is not assignable to type 'C'. class C { _brand: any; static m() {} diff --git a/tests/baselines/reference/deepExcessPropertyCheckingWhenTargetIsIntersection.errors.txt b/tests/baselines/reference/deepExcessPropertyCheckingWhenTargetIsIntersection.errors.txt index 6a83638ba90..1f2552d47f2 100644 --- a/tests/baselines/reference/deepExcessPropertyCheckingWhenTargetIsIntersection.errors.txt +++ b/tests/baselines/reference/deepExcessPropertyCheckingWhenTargetIsIntersection.errors.txt @@ -1,10 +1,8 @@ tests/cases/compiler/deepExcessPropertyCheckingWhenTargetIsIntersection.ts(21,33): error TS2322: Type '{ INVALID_PROP_NAME: string; ariaLabel: string; }' is not assignable to type 'ITestProps'. Object literal may only specify known properties, and 'INVALID_PROP_NAME' does not exist in type 'ITestProps'. -tests/cases/compiler/deepExcessPropertyCheckingWhenTargetIsIntersection.ts(27,34): error TS2326: Types of property 'icon' are incompatible. - Type '{ props: { INVALID_PROP_NAME: string; ariaLabel: string; }; }' is not assignable to type 'NestedProp'. - Types of property 'props' are incompatible. - Type '{ INVALID_PROP_NAME: string; ariaLabel: string; }' is not assignable to type 'ITestProps'. - Object literal may only specify known properties, and 'INVALID_PROP_NAME' does not exist in type 'ITestProps'. +tests/cases/compiler/deepExcessPropertyCheckingWhenTargetIsIntersection.ts(27,34): error TS2200: The types of 'icon.props' are incompatible between these types. + Type '{ INVALID_PROP_NAME: string; ariaLabel: string; }' is not assignable to type 'ITestProps'. + Object literal may only specify known properties, and 'INVALID_PROP_NAME' does not exist in type 'ITestProps'. ==== tests/cases/compiler/deepExcessPropertyCheckingWhenTargetIsIntersection.ts (2 errors) ==== @@ -40,9 +38,7 @@ tests/cases/compiler/deepExcessPropertyCheckingWhenTargetIsIntersection.ts(27,34 TestComponent2({icon: { props: { INVALID_PROP_NAME: 'share', ariaLabel: 'test label' } }}); ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2326: Types of property 'icon' are incompatible. -!!! error TS2326: Type '{ props: { INVALID_PROP_NAME: string; ariaLabel: string; }; }' is not assignable to type 'NestedProp'. -!!! error TS2326: Types of property 'props' are incompatible. -!!! error TS2326: Type '{ INVALID_PROP_NAME: string; ariaLabel: string; }' is not assignable to type 'ITestProps'. -!!! error TS2326: Object literal may only specify known properties, and 'INVALID_PROP_NAME' does not exist in type 'ITestProps'. +!!! error TS2200: The types of 'icon.props' are incompatible between these types. +!!! error TS2200: Type '{ INVALID_PROP_NAME: string; ariaLabel: string; }' is not assignable to type 'ITestProps'. +!!! error TS2200: Object literal may only specify known properties, and 'INVALID_PROP_NAME' does not exist in type 'ITestProps'. \ No newline at end of file diff --git a/tests/baselines/reference/deeplyNestedAssignabilityErrorsCombined.errors.txt b/tests/baselines/reference/deeplyNestedAssignabilityErrorsCombined.errors.txt new file mode 100644 index 00000000000..6245d06d2b7 --- /dev/null +++ b/tests/baselines/reference/deeplyNestedAssignabilityErrorsCombined.errors.txt @@ -0,0 +1,32 @@ +tests/cases/compiler/deeplyNestedAssignabilityErrorsCombined.ts(3,1): error TS2322: Type '{ a: { b: { c: { d: { e: { f(): { g: number; }; }; }; }; }; }; }' is not assignable to type '{ a: { b: { c: { d: { e: { f(): { g: string; }; }; }; }; }; }; }'. + The types of 'a.b.c.d.e.f().g' are incompatible between these types. + Type 'number' is not assignable to type 'string'. +tests/cases/compiler/deeplyNestedAssignabilityErrorsCombined.ts(15,1): error TS2322: Type '{ a: { b: { c: { d: { e: { f: typeof Ctor2; }; }; }; }; }; }' is not assignable to type '{ a: { b: { c: { d: { e: { f: typeof Ctor1; }; }; }; }; }; }'. + The types of '(new a.b.c.d.e.f()).g' are incompatible between these types. + Type 'number' is not assignable to type 'string'. + + +==== tests/cases/compiler/deeplyNestedAssignabilityErrorsCombined.ts (2 errors) ==== + let x = { a: { b: { c: { d: { e: { f() { return { g: "hello" }; } } } } } } }; + let y = { a: { b: { c: { d: { e: { f() { return { g: 12345 }; } } } } } } }; + x = y; + ~ +!!! error TS2322: Type '{ a: { b: { c: { d: { e: { f(): { g: number; }; }; }; }; }; }; }' is not assignable to type '{ a: { b: { c: { d: { e: { f(): { g: string; }; }; }; }; }; }; }'. +!!! error TS2322: The types of 'a.b.c.d.e.f().g' are incompatible between these types. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + class Ctor1 { + g = "ok" + } + + class Ctor2 { + g = 12; + } + + let x2 = { a: { b: { c: { d: { e: { f: Ctor1 } } } } } }; + let y2 = { a: { b: { c: { d: { e: { f: Ctor2 } } } } } }; + x2 = y2; + ~~ +!!! error TS2322: Type '{ a: { b: { c: { d: { e: { f: typeof Ctor2; }; }; }; }; }; }' is not assignable to type '{ a: { b: { c: { d: { e: { f: typeof Ctor1; }; }; }; }; }; }'. +!!! error TS2322: The types of '(new a.b.c.d.e.f()).g' are incompatible between these types. +!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/deeplyNestedAssignabilityErrorsCombined.js b/tests/baselines/reference/deeplyNestedAssignabilityErrorsCombined.js new file mode 100644 index 00000000000..01bdcc7f253 --- /dev/null +++ b/tests/baselines/reference/deeplyNestedAssignabilityErrorsCombined.js @@ -0,0 +1,36 @@ +//// [deeplyNestedAssignabilityErrorsCombined.ts] +let x = { a: { b: { c: { d: { e: { f() { return { g: "hello" }; } } } } } } }; +let y = { a: { b: { c: { d: { e: { f() { return { g: 12345 }; } } } } } } }; +x = y; + +class Ctor1 { + g = "ok" +} + +class Ctor2 { + g = 12; +} + +let x2 = { a: { b: { c: { d: { e: { f: Ctor1 } } } } } }; +let y2 = { a: { b: { c: { d: { e: { f: Ctor2 } } } } } }; +x2 = y2; + +//// [deeplyNestedAssignabilityErrorsCombined.js] +var x = { a: { b: { c: { d: { e: { f: function () { return { g: "hello" }; } } } } } } }; +var y = { a: { b: { c: { d: { e: { f: function () { return { g: 12345 }; } } } } } } }; +x = y; +var Ctor1 = /** @class */ (function () { + function Ctor1() { + this.g = "ok"; + } + return Ctor1; +}()); +var Ctor2 = /** @class */ (function () { + function Ctor2() { + this.g = 12; + } + return Ctor2; +}()); +var x2 = { a: { b: { c: { d: { e: { f: Ctor1 } } } } } }; +var y2 = { a: { b: { c: { d: { e: { f: Ctor2 } } } } } }; +x2 = y2; diff --git a/tests/baselines/reference/deeplyNestedAssignabilityErrorsCombined.symbols b/tests/baselines/reference/deeplyNestedAssignabilityErrorsCombined.symbols new file mode 100644 index 00000000000..12333869923 --- /dev/null +++ b/tests/baselines/reference/deeplyNestedAssignabilityErrorsCombined.symbols @@ -0,0 +1,63 @@ +=== tests/cases/compiler/deeplyNestedAssignabilityErrorsCombined.ts === +let x = { a: { b: { c: { d: { e: { f() { return { g: "hello" }; } } } } } } }; +>x : Symbol(x, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 0, 3)) +>a : Symbol(a, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 0, 9)) +>b : Symbol(b, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 0, 14)) +>c : Symbol(c, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 0, 19)) +>d : Symbol(d, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 0, 24)) +>e : Symbol(e, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 0, 29)) +>f : Symbol(f, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 0, 34)) +>g : Symbol(g, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 0, 49)) + +let y = { a: { b: { c: { d: { e: { f() { return { g: 12345 }; } } } } } } }; +>y : Symbol(y, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 1, 3)) +>a : Symbol(a, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 1, 9)) +>b : Symbol(b, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 1, 14)) +>c : Symbol(c, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 1, 19)) +>d : Symbol(d, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 1, 24)) +>e : Symbol(e, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 1, 29)) +>f : Symbol(f, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 1, 34)) +>g : Symbol(g, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 1, 49)) + +x = y; +>x : Symbol(x, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 0, 3)) +>y : Symbol(y, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 1, 3)) + +class Ctor1 { +>Ctor1 : Symbol(Ctor1, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 2, 6)) + + g = "ok" +>g : Symbol(Ctor1.g, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 4, 13)) +} + +class Ctor2 { +>Ctor2 : Symbol(Ctor2, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 6, 1)) + + g = 12; +>g : Symbol(Ctor2.g, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 8, 13)) +} + +let x2 = { a: { b: { c: { d: { e: { f: Ctor1 } } } } } }; +>x2 : Symbol(x2, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 12, 3)) +>a : Symbol(a, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 12, 10)) +>b : Symbol(b, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 12, 15)) +>c : Symbol(c, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 12, 20)) +>d : Symbol(d, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 12, 25)) +>e : Symbol(e, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 12, 30)) +>f : Symbol(f, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 12, 35)) +>Ctor1 : Symbol(Ctor1, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 2, 6)) + +let y2 = { a: { b: { c: { d: { e: { f: Ctor2 } } } } } }; +>y2 : Symbol(y2, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 13, 3)) +>a : Symbol(a, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 13, 10)) +>b : Symbol(b, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 13, 15)) +>c : Symbol(c, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 13, 20)) +>d : Symbol(d, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 13, 25)) +>e : Symbol(e, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 13, 30)) +>f : Symbol(f, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 13, 35)) +>Ctor2 : Symbol(Ctor2, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 6, 1)) + +x2 = y2; +>x2 : Symbol(x2, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 12, 3)) +>y2 : Symbol(y2, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 13, 3)) + diff --git a/tests/baselines/reference/deeplyNestedAssignabilityErrorsCombined.types b/tests/baselines/reference/deeplyNestedAssignabilityErrorsCombined.types new file mode 100644 index 00000000000..565de61ef08 --- /dev/null +++ b/tests/baselines/reference/deeplyNestedAssignabilityErrorsCombined.types @@ -0,0 +1,95 @@ +=== tests/cases/compiler/deeplyNestedAssignabilityErrorsCombined.ts === +let x = { a: { b: { c: { d: { e: { f() { return { g: "hello" }; } } } } } } }; +>x : { a: { b: { c: { d: { e: { f(): { g: string; }; }; }; }; }; }; } +>{ a: { b: { c: { d: { e: { f() { return { g: "hello" }; } } } } } } } : { a: { b: { c: { d: { e: { f(): { g: string; }; }; }; }; }; }; } +>a : { b: { c: { d: { e: { f(): { g: string; }; }; }; }; }; } +>{ b: { c: { d: { e: { f() { return { g: "hello" }; } } } } } } : { b: { c: { d: { e: { f(): { g: string; }; }; }; }; }; } +>b : { c: { d: { e: { f(): { g: string; }; }; }; }; } +>{ c: { d: { e: { f() { return { g: "hello" }; } } } } } : { c: { d: { e: { f(): { g: string; }; }; }; }; } +>c : { d: { e: { f(): { g: string; }; }; }; } +>{ d: { e: { f() { return { g: "hello" }; } } } } : { d: { e: { f(): { g: string; }; }; }; } +>d : { e: { f(): { g: string; }; }; } +>{ e: { f() { return { g: "hello" }; } } } : { e: { f(): { g: string; }; }; } +>e : { f(): { g: string; }; } +>{ f() { return { g: "hello" }; } } : { f(): { g: string; }; } +>f : () => { g: string; } +>{ g: "hello" } : { g: string; } +>g : string +>"hello" : "hello" + +let y = { a: { b: { c: { d: { e: { f() { return { g: 12345 }; } } } } } } }; +>y : { a: { b: { c: { d: { e: { f(): { g: number; }; }; }; }; }; }; } +>{ a: { b: { c: { d: { e: { f() { return { g: 12345 }; } } } } } } } : { a: { b: { c: { d: { e: { f(): { g: number; }; }; }; }; }; }; } +>a : { b: { c: { d: { e: { f(): { g: number; }; }; }; }; }; } +>{ b: { c: { d: { e: { f() { return { g: 12345 }; } } } } } } : { b: { c: { d: { e: { f(): { g: number; }; }; }; }; }; } +>b : { c: { d: { e: { f(): { g: number; }; }; }; }; } +>{ c: { d: { e: { f() { return { g: 12345 }; } } } } } : { c: { d: { e: { f(): { g: number; }; }; }; }; } +>c : { d: { e: { f(): { g: number; }; }; }; } +>{ d: { e: { f() { return { g: 12345 }; } } } } : { d: { e: { f(): { g: number; }; }; }; } +>d : { e: { f(): { g: number; }; }; } +>{ e: { f() { return { g: 12345 }; } } } : { e: { f(): { g: number; }; }; } +>e : { f(): { g: number; }; } +>{ f() { return { g: 12345 }; } } : { f(): { g: number; }; } +>f : () => { g: number; } +>{ g: 12345 } : { g: number; } +>g : number +>12345 : 12345 + +x = y; +>x = y : { a: { b: { c: { d: { e: { f(): { g: number; }; }; }; }; }; }; } +>x : { a: { b: { c: { d: { e: { f(): { g: string; }; }; }; }; }; }; } +>y : { a: { b: { c: { d: { e: { f(): { g: number; }; }; }; }; }; }; } + +class Ctor1 { +>Ctor1 : Ctor1 + + g = "ok" +>g : string +>"ok" : "ok" +} + +class Ctor2 { +>Ctor2 : Ctor2 + + g = 12; +>g : number +>12 : 12 +} + +let x2 = { a: { b: { c: { d: { e: { f: Ctor1 } } } } } }; +>x2 : { a: { b: { c: { d: { e: { f: typeof Ctor1; }; }; }; }; }; } +>{ a: { b: { c: { d: { e: { f: Ctor1 } } } } } } : { a: { b: { c: { d: { e: { f: typeof Ctor1; }; }; }; }; }; } +>a : { b: { c: { d: { e: { f: typeof Ctor1; }; }; }; }; } +>{ b: { c: { d: { e: { f: Ctor1 } } } } } : { b: { c: { d: { e: { f: typeof Ctor1; }; }; }; }; } +>b : { c: { d: { e: { f: typeof Ctor1; }; }; }; } +>{ c: { d: { e: { f: Ctor1 } } } } : { c: { d: { e: { f: typeof Ctor1; }; }; }; } +>c : { d: { e: { f: typeof Ctor1; }; }; } +>{ d: { e: { f: Ctor1 } } } : { d: { e: { f: typeof Ctor1; }; }; } +>d : { e: { f: typeof Ctor1; }; } +>{ e: { f: Ctor1 } } : { e: { f: typeof Ctor1; }; } +>e : { f: typeof Ctor1; } +>{ f: Ctor1 } : { f: typeof Ctor1; } +>f : typeof Ctor1 +>Ctor1 : typeof Ctor1 + +let y2 = { a: { b: { c: { d: { e: { f: Ctor2 } } } } } }; +>y2 : { a: { b: { c: { d: { e: { f: typeof Ctor2; }; }; }; }; }; } +>{ a: { b: { c: { d: { e: { f: Ctor2 } } } } } } : { a: { b: { c: { d: { e: { f: typeof Ctor2; }; }; }; }; }; } +>a : { b: { c: { d: { e: { f: typeof Ctor2; }; }; }; }; } +>{ b: { c: { d: { e: { f: Ctor2 } } } } } : { b: { c: { d: { e: { f: typeof Ctor2; }; }; }; }; } +>b : { c: { d: { e: { f: typeof Ctor2; }; }; }; } +>{ c: { d: { e: { f: Ctor2 } } } } : { c: { d: { e: { f: typeof Ctor2; }; }; }; } +>c : { d: { e: { f: typeof Ctor2; }; }; } +>{ d: { e: { f: Ctor2 } } } : { d: { e: { f: typeof Ctor2; }; }; } +>d : { e: { f: typeof Ctor2; }; } +>{ e: { f: Ctor2 } } : { e: { f: typeof Ctor2; }; } +>e : { f: typeof Ctor2; } +>{ f: Ctor2 } : { f: typeof Ctor2; } +>f : typeof Ctor2 +>Ctor2 : typeof Ctor2 + +x2 = y2; +>x2 = y2 : { a: { b: { c: { d: { e: { f: typeof Ctor2; }; }; }; }; }; } +>x2 : { a: { b: { c: { d: { e: { f: typeof Ctor1; }; }; }; }; }; } +>y2 : { a: { b: { c: { d: { e: { f: typeof Ctor2; }; }; }; }; }; } + diff --git a/tests/baselines/reference/destructuringControlFlow.types b/tests/baselines/reference/destructuringControlFlow.types index 347aae32c10..b6b9967ba43 100644 --- a/tests/baselines/reference/destructuringControlFlow.types +++ b/tests/baselines/reference/destructuringControlFlow.types @@ -161,7 +161,7 @@ function f4() { // Repro from #31770 type KeyValue = [string, string?]; ->KeyValue : [string, (string | undefined)?] +>KeyValue : KeyValue let [key, value]: KeyValue = ["foo"]; >key : string diff --git a/tests/baselines/reference/destructuringInFunctionType.types b/tests/baselines/reference/destructuringInFunctionType.types index c6c0f439ac5..b5b0ff041c6 100644 --- a/tests/baselines/reference/destructuringInFunctionType.types +++ b/tests/baselines/reference/destructuringInFunctionType.types @@ -9,7 +9,7 @@ interface c { c } >c : any type T1 = ([a, b, c]); ->T1 : [a, b, c] +>T1 : T1 type F1 = ([a, b, c]) => void; >F1 : F1 @@ -26,7 +26,7 @@ type F2 = ({ a }) => void; >a : any type T3 = ([{ a: b }, { b: a }]); ->T3 : [{ a: b; }, { b: a; }] +>T3 : T3 >a : b >b : a @@ -38,7 +38,7 @@ type F3 = ([{ a: b }, { b: a }]) => void; >a : any type T4 = ([{ a: [b, c] }]); ->T4 : [{ a: [b, c]; }] +>T4 : T4 >a : [b, c] type F4 = ([{ a: [b, c] }]) => void; diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5.types b/tests/baselines/reference/destructuringParameterDeclaration3ES5.types index 96681054bd9..a18a2c4f0a9 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES5.types +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5.types @@ -6,13 +6,13 @@ // ... Identifier TypeAnnotation(opt) type arrayString = Array ->arrayString : String[] +>arrayString : arrayString type someArray = Array | number[]; >someArray : someArray type stringOrNumArray = Array; ->stringOrNumArray : (String | Number)[] +>stringOrNumArray : stringOrNumArray function a1(...x: (number|string)[]) { } >a1 : (...x: (string | number)[]) => void @@ -27,12 +27,12 @@ function a3(...a: Array) { } >a : String[] function a4(...a: arrayString) { } ->a4 : (...a: String[]) => void ->a : String[] +>a4 : (...a: arrayString) => void +>a : arrayString function a5(...a: stringOrNumArray) { } ->a5 : (...a: (String | Number)[]) => void ->a : (String | Number)[] +>a5 : (...a: stringOrNumArray) => void +>a : stringOrNumArray function a9([a, b, [[c]]]) { } >a9 : ([a, b, [[c]]]: [any, any, [[any]]]) => void diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.types b/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.types index 441a079e4ab..e41c2e5d75a 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.types +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.types @@ -6,13 +6,13 @@ // ... Identifier TypeAnnotation(opt) type arrayString = Array ->arrayString : String[] +>arrayString : arrayString type someArray = Array | number[]; >someArray : someArray type stringOrNumArray = Array; ->stringOrNumArray : (String | Number)[] +>stringOrNumArray : stringOrNumArray function a1(...x: (number|string)[]) { } >a1 : (...x: (string | number)[]) => void @@ -27,12 +27,12 @@ function a3(...a: Array) { } >a : String[] function a4(...a: arrayString) { } ->a4 : (...a: String[]) => void ->a : String[] +>a4 : (...a: arrayString) => void +>a : arrayString function a5(...a: stringOrNumArray) { } ->a5 : (...a: (String | Number)[]) => void ->a : (String | Number)[] +>a5 : (...a: stringOrNumArray) => void +>a : stringOrNumArray function a9([a, b, [[c]]]) { } >a9 : ([a, b, [[c]]]: [any, any, [[any]]]) => void diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES6.types b/tests/baselines/reference/destructuringParameterDeclaration3ES6.types index a7fcb861e4c..4adacfd11ff 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES6.types +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES6.types @@ -6,13 +6,13 @@ // ... Identifier TypeAnnotation(opt) type arrayString = Array ->arrayString : String[] +>arrayString : arrayString type someArray = Array | number[]; >someArray : someArray type stringOrNumArray = Array; ->stringOrNumArray : (String | Number)[] +>stringOrNumArray : stringOrNumArray function a1(...x: (number|string)[]) { } >a1 : (...x: (string | number)[]) => void @@ -27,12 +27,12 @@ function a3(...a: Array) { } >a : String[] function a4(...a: arrayString) { } ->a4 : (...a: String[]) => void ->a : String[] +>a4 : (...a: arrayString) => void +>a : arrayString function a5(...a: stringOrNumArray) { } ->a5 : (...a: (String | Number)[]) => void ->a : (String | Number)[] +>a5 : (...a: stringOrNumArray) => void +>a : stringOrNumArray function a9([a, b, [[c]]]) { } >a9 : ([a, b, [[c]]]: [any, any, [[any]]]) => void diff --git a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt index 7cd59c5a93a..0cfa02e8508 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:13: 'Array' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1373: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/destructuringParameterDeclaration4.types b/tests/baselines/reference/destructuringParameterDeclaration4.types index 444a70ff196..2c3a7dc5f95 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration4.types +++ b/tests/baselines/reference/destructuringParameterDeclaration4.types @@ -6,13 +6,13 @@ // ... Identifier TypeAnnotation(opt) type arrayString = Array ->arrayString : String[] +>arrayString : arrayString type someArray = Array | number[]; >someArray : someArray type stringOrNumArray = Array; ->stringOrNumArray : (String | Number)[] +>stringOrNumArray : stringOrNumArray function a0(...x: [number, number, string]) { } // Error, rest parameter must be array type >a0 : (x_0: number, x_1: number, x_2: string) => void diff --git a/tests/baselines/reference/destructuringParameterProperties1.types b/tests/baselines/reference/destructuringParameterProperties1.types index ff12edbac2e..13bacf49b13 100644 --- a/tests/baselines/reference/destructuringParameterProperties1.types +++ b/tests/baselines/reference/destructuringParameterProperties1.types @@ -10,7 +10,7 @@ class C1 { } type TupleType1 = [string, number, boolean]; ->TupleType1 : [string, number, boolean] +>TupleType1 : TupleType1 class C2 { >C2 : C2 diff --git a/tests/baselines/reference/destructuringParameterProperties5.types b/tests/baselines/reference/destructuringParameterProperties5.types index 60c3d074c6e..976b79e9495 100644 --- a/tests/baselines/reference/destructuringParameterProperties5.types +++ b/tests/baselines/reference/destructuringParameterProperties5.types @@ -6,7 +6,7 @@ type ObjType1 = { x: number; y: string; z: boolean } >z : boolean type TupleType1 = [ObjType1, number, string] ->TupleType1 : [ObjType1, number, string] +>TupleType1 : TupleType1 class C1 { >C1 : C1 diff --git a/tests/baselines/reference/directDependenceBetweenTypeAliases.errors.txt b/tests/baselines/reference/directDependenceBetweenTypeAliases.errors.txt index 68ea92f8fb5..374cef0c1cb 100644 --- a/tests/baselines/reference/directDependenceBetweenTypeAliases.errors.txt +++ b/tests/baselines/reference/directDependenceBetweenTypeAliases.errors.txt @@ -2,20 +2,12 @@ tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts( tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(5,6): error TS2456: Type alias 'T0_1' circularly references itself. tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(6,6): error TS2456: Type alias 'T0_2' circularly references itself. tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(7,6): error TS2456: Type alias 'T0_3' circularly references itself. -tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(11,6): error TS2456: Type alias 'T1' circularly references itself. tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(14,6): error TS2456: Type alias 'T2' circularly references itself. -tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(16,6): error TS2456: Type alias 'T2_1' circularly references itself. -tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(19,6): error TS2456: Type alias 'T3' circularly references itself. -tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(22,6): error TS2456: Type alias 'T4' circularly references itself. tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(25,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(26,6): error TS2456: Type alias 'T5' circularly references itself. -tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(29,6): error TS2456: Type alias 'T6' circularly references itself. -tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(30,6): error TS2456: Type alias 'T7' circularly references itself. -tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(31,5): error TS2502: 'yy' is referenced directly or indirectly in its own type annotation. -tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(32,6): error TS2456: Type alias 'T8' circularly references itself. -==== tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts (15 errors) ==== +==== tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts (7 errors) ==== // It is an error for the type specified in a type alias to depend on that type alias // A type alias directly depends on the type it aliases. @@ -35,8 +27,6 @@ tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts( // A type reference directly depends on the referenced type and each of the type arguments, if any. interface I {} type T1 = I - ~~ -!!! error TS2456: Type alias 'T1' circularly references itself. // A union type directly depends on each of the constituent types. type T2 = T2 | string @@ -44,18 +34,12 @@ tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts( !!! error TS2456: Type alias 'T2' circularly references itself. class C {} type T2_1 = T2_1[] | number - ~~~~ -!!! error TS2456: Type alias 'T2_1' circularly references itself. // An array type directly depends on its element type. type T3 = T3[] - ~~ -!!! error TS2456: Type alias 'T3' circularly references itself. // A tuple type directly depends on each of its element types. type T4 = [number, T4] - ~~ -!!! error TS2456: Type alias 'T4' circularly references itself. // A type query directly depends on the type of the referenced entity. var x: T5[] = [] @@ -67,17 +51,9 @@ tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts( class C1 {} type T6 = T7 | number - ~~ -!!! error TS2456: Type alias 'T6' circularly references itself. type T7 = typeof yy - ~~ -!!! error TS2456: Type alias 'T7' circularly references itself. var yy: [string, T8[]]; - ~~ -!!! error TS2502: 'yy' is referenced directly or indirectly in its own type annotation. type T8 = C - ~~ -!!! error TS2456: Type alias 'T8' circularly references itself. // legal cases type T9 = () => T9 diff --git a/tests/baselines/reference/directDependenceBetweenTypeAliases.types b/tests/baselines/reference/directDependenceBetweenTypeAliases.types index 3363b20b851..e1d6784b327 100644 --- a/tests/baselines/reference/directDependenceBetweenTypeAliases.types +++ b/tests/baselines/reference/directDependenceBetweenTypeAliases.types @@ -17,7 +17,7 @@ type T0_3 = T0_1 // A type reference directly depends on the referenced type and each of the type arguments, if any. interface I {} type T1 = I ->T1 : any +>T1 : T1 // A union type directly depends on each of the constituent types. type T2 = T2 | string @@ -27,15 +27,15 @@ class C {} >C : C type T2_1 = T2_1[] | number ->T2_1 : any +>T2_1 : T2_1 // An array type directly depends on its element type. type T3 = T3[] ->T3 : any +>T3 : T3 // A tuple type directly depends on each of its element types. type T4 = [number, T4] ->T4 : any +>T4 : T4 // A type query directly depends on the type of the referenced entity. var x: T5[] = [] @@ -50,17 +50,17 @@ class C1 {} >C1 : C1 type T6 = T7 | number ->T6 : any +>T6 : T6 type T7 = typeof yy ->T7 : any ->yy : any +>T7 : [string, T8[]] +>yy : [string, T8[]] var yy: [string, T8[]]; ->yy : any +>yy : [string, T8[]] type T8 = C ->T8 : any +>T8 : T8 // legal cases type T9 = () => T9 @@ -72,17 +72,17 @@ type T10 = { x: T10 } | { new(v: T10): string } >v : T10 type T11 = T12[] ->T11 : [{ x: [any, string][]; }, string][] +>T11 : T11 type T12 = [T13, string] ->T12 : [{ x: [any, string][]; }, string] +>T12 : T12 type T13 = typeof zz ->T13 : { x: [any, string][]; } ->zz : { x: [any, string][]; } +>T13 : { x: T11; } +>zz : { x: T11; } var zz: { x: T11 } ->zz : { x: [any, string][]; } ->x : [{ x: [any, string][]; }, string][] +>zz : { x: T11; } +>x : T11 diff --git a/tests/baselines/reference/docker/azure-sdk.log b/tests/baselines/reference/docker/azure-sdk.log index ba878ab443a..6a02c105f95 100644 --- a/tests/baselines/reference/docker/azure-sdk.log +++ b/tests/baselines/reference/docker/azure-sdk.log @@ -57,7 +57,7 @@ atob (guessing 'atob') (!) Circular dependency: dist-esm/request/RequestHandler.js -> dist-esm/retry/retryUtility.js -> dist-esm/request/RequestHandler.js created dist/index.js in ?s XX of XX: [@azure/eventhubs-checkpointstore-blob] completed successfully in ? seconds -XX of XX: [@azure/keyvault-certificates] completed successfully in ? seconds +XX of XX: [@azure/keyvault-certificates] completed successfully in ? seconds Warning: You have changed the public API signature for this project. Updating review/service-bus.api.md XX of XX: [@azure/storage-blob] completed successfully in ? seconds XX of XX: [@azure/storage-file] completed successfully in ? seconds @@ -81,7 +81,7 @@ SUCCESS (21) @azure/keyvault-secrets (? seconds) @azure/core-asynciterator-polyfill (? seconds) @azure/eventhubs-checkpointstore-blob (? seconds) -@azure/keyvault-certificates (? seconds) +@azure/keyvault-certificates ( ? seconds) @azure/storage-blob (? seconds) @azure/storage-file (? seconds) @azure/storage-queue (? seconds) diff --git a/tests/baselines/reference/docker/office-ui-fabric.log b/tests/baselines/reference/docker/office-ui-fabric.log index 7bd402b8327..7a8f1b1dcf8 100644 --- a/tests/baselines/reference/docker/office-ui-fabric.log +++ b/tests/baselines/reference/docker/office-ui-fabric.log @@ -1,14 +1,5 @@ Exit Code: 1 Standard output: -@uifabric/codepen-loader: yarn run vX.X.X -@uifabric/codepen-loader: $ just-scripts build --production --lint -@uifabric/codepen-loader: [XX:XX:XX XM] â–  Removing [lib, temp, dist, coverage, lib-commonjs] -@uifabric/codepen-loader: [XX:XX:XX XM] â–  Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/codepen-loader/tsconfig.json -@uifabric/codepen-loader: [XX:XX:XX XM] â–  Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --module commonjs --outDir "./lib" --project "/office-ui-fabric-react/packages/codepen-loader/tsconfig.json" -@uifabric/codepen-loader: [XX:XX:XX XM] â–  Running Jest -@uifabric/codepen-loader: [XX:XX:XX XM] â–  /usr/local/bin/node "/office-ui-fabric-react/node_modules/jest/bin/jest.js" --config "/office-ui-fabric-react/packages/codepen-loader/jest.config.js" --passWithNoTests --colors --forceExit -@uifabric/codepen-loader: PASS src/__tests__/codepenTransform.test.ts -@uifabric/codepen-loader: Done in ?s. @uifabric/build: yarn run vX.X.X @uifabric/build: $ node ./just-scripts.js no-op --production --lint @uifabric/build: Done in ?s. @@ -36,9 +27,11 @@ Standard output: @uifabric/migration: Done in ?s. @uifabric/monaco-editor: yarn run vX.X.X @uifabric/monaco-editor: $ just-scripts build --production --lint -@uifabric/monaco-editor: [XX:XX:XX XM] â–  Removing [esm, lib] +@uifabric/monaco-editor: [XX:XX:XX XM] â–  Removing [esm, lib, lib-commonjs] @uifabric/monaco-editor: [XX:XX:XX XM] â–  Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/monaco-editor/tsconfig.json @uifabric/monaco-editor: [XX:XX:XX XM] â–  Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --inlineSources --sourceRoot "../src" --outDir lib --module esnext --project "/office-ui-fabric-react/packages/monaco-editor/tsconfig.json" +@uifabric/monaco-editor: [XX:XX:XX XM] â–  Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/monaco-editor/tsconfig.json +@uifabric/monaco-editor: [XX:XX:XX XM] â–  Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --inlineSources --sourceRoot "../src" --outDir lib-commonjs --module commonjs --project "/office-ui-fabric-react/packages/monaco-editor/tsconfig.json" @uifabric/monaco-editor: Done in ?s. @uifabric/set-version: yarn run vX.X.X @uifabric/set-version: $ just-scripts build --production --lint @@ -91,6 +84,7 @@ Standard output: @uifabric/merge-styles: PASS src/extractStyleParts.test.ts @uifabric/merge-styles: PASS src/server.test.ts @uifabric/merge-styles: PASS src/concatStyleSetsWithProps.test.ts +@uifabric/merge-styles: PASS src/fontFace.test.ts @uifabric/merge-styles: [XX:XX:XX XM] â–  Extracting Public API surface from '/office-ui-fabric-react/packages/merge-styles/lib/index.d.ts' @uifabric/merge-styles: Done in ?s. @uifabric/jest-serializer-merge-styles: yarn run vX.X.X @@ -134,9 +128,9 @@ Standard output: @uifabric/utilities: PASS src/warn/warnControlledUsage.test.ts @uifabric/utilities: PASS src/focus.test.tsx @uifabric/utilities: PASS src/styled.test.tsx +@uifabric/utilities: PASS src/customizations/Customizer.test.tsx @uifabric/utilities: PASS src/EventGroup.test.ts @uifabric/utilities: PASS src/array.test.ts -@uifabric/utilities: PASS src/customizations/Customizer.test.tsx @uifabric/utilities: PASS src/math.test.ts @uifabric/utilities: PASS src/warn/warn.test.ts @uifabric/utilities: PASS src/dom/dom.test.ts @@ -249,11 +243,7 @@ Standard output: Standard error: info cli using local version of lerna lerna notice cli vX.X.X -lerna info Executing command in 43 packages: "yarn run build --production --lint" -@uifabric/codepen-loader: ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. -@uifabric/codepen-loader: Force exiting Jest -@uifabric/codepen-loader: -@uifabric/codepen-loader: Have you considered using `--detectOpenHandles` to detect async operations that kept running after all tests finished? +lerna info Executing command in 42 packages: "yarn run build --production --lint" @uifabric/example-data: [XX:XX:XX XM] â–² One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect @uifabric/set-version: [XX:XX:XX XM] â–² One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect @uifabric/merge-styles: [XX:XX:XX XM] â–² One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect diff --git a/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.errors.txt b/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.errors.txt index dc7e3f10bd1..b84fb863ad8 100644 --- a/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.errors.txt +++ b/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.errors.txt @@ -1,9 +1,7 @@ tests/cases/compiler/elaboratedErrorsOnNullableTargets01.ts(4,1): error TS2322: Type '{ foo: { bar: number | undefined; }; }' is not assignable to type '{ foo: { bar: string | null; } | undefined; }'. - Types of property 'foo' are incompatible. - Type '{ bar: number | undefined; }' is not assignable to type '{ bar: string | null; }'. - Types of property 'bar' are incompatible. - Type 'number | undefined' is not assignable to type 'string | null'. - Type 'undefined' is not assignable to type 'string | null'. + The types of 'foo.bar' are incompatible between these types. + Type 'number | undefined' is not assignable to type 'string | null'. + Type 'undefined' is not assignable to type 'string | null'. tests/cases/compiler/elaboratedErrorsOnNullableTargets01.ts(6,1): error TS2322: Type '{ foo: { bar: string | null; } | undefined; } | null | undefined' is not assignable to type '{ foo: { bar: number | undefined; }; }'. Type 'undefined' is not assignable to type '{ foo: { bar: number | undefined; }; }'. @@ -15,11 +13,9 @@ tests/cases/compiler/elaboratedErrorsOnNullableTargets01.ts(6,1): error TS2322: x = y; ~ !!! error TS2322: Type '{ foo: { bar: number | undefined; }; }' is not assignable to type '{ foo: { bar: string | null; } | undefined; }'. -!!! error TS2322: Types of property 'foo' are incompatible. -!!! error TS2322: Type '{ bar: number | undefined; }' is not assignable to type '{ bar: string | null; }'. -!!! error TS2322: Types of property 'bar' are incompatible. -!!! error TS2322: Type 'number | undefined' is not assignable to type 'string | null'. -!!! error TS2322: Type 'undefined' is not assignable to type 'string | null'. +!!! error TS2322: The types of 'foo.bar' are incompatible between these types. +!!! error TS2322: Type 'number | undefined' is not assignable to type 'string | null'. +!!! error TS2322: Type 'undefined' is not assignable to type 'string | null'. y = x; ~ diff --git a/tests/baselines/reference/everyTypeWithAnnotationAndInvalidInitializer.errors.txt b/tests/baselines/reference/everyTypeWithAnnotationAndInvalidInitializer.errors.txt index 31848458a87..f552bb35ca4 100644 --- a/tests/baselines/reference/everyTypeWithAnnotationAndInvalidInitializer.errors.txt +++ b/tests/baselines/reference/everyTypeWithAnnotationAndInvalidInitializer.errors.txt @@ -17,9 +17,8 @@ tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAnd Type 'string' is not assignable to type 'number'. tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(48,32): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(50,5): error TS2322: Type 'typeof N' is not assignable to type 'typeof M'. - Types of property 'A' are incompatible. - Type 'typeof N.A' is not assignable to type 'typeof M.A'. - Property 'name' is missing in type 'N.A' but required in type 'M.A'. + The types returned by 'new A()' are incompatible between these types. + Property 'name' is missing in type 'N.A' but required in type 'M.A'. tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(51,5): error TS2322: Type 'N.A' is not assignable to type 'M.A'. tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(52,5): error TS2322: Type '(x: number) => boolean' is not assignable to type '(x: number) => string'. Type 'boolean' is not assignable to type 'string'. @@ -112,9 +111,8 @@ tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAnd var aModule: typeof M = N; ~~~~~~~ !!! error TS2322: Type 'typeof N' is not assignable to type 'typeof M'. -!!! error TS2322: Types of property 'A' are incompatible. -!!! error TS2322: Type 'typeof N.A' is not assignable to type 'typeof M.A'. -!!! error TS2322: Property 'name' is missing in type 'N.A' but required in type 'M.A'. +!!! error TS2322: The types returned by 'new A()' are incompatible between these types. +!!! error TS2322: Property 'name' is missing in type 'N.A' but required in type 'M.A'. !!! related TS2728 tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts:20:9: 'name' is declared here. var aClassInModule: M.A = new N.A(); ~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/exhaustiveSwitchImplicitReturn.errors.txt b/tests/baselines/reference/exhaustiveSwitchImplicitReturn.errors.txt index 43b5467f0d2..89daa42c268 100644 --- a/tests/baselines/reference/exhaustiveSwitchImplicitReturn.errors.txt +++ b/tests/baselines/reference/exhaustiveSwitchImplicitReturn.errors.txt @@ -44,4 +44,18 @@ tests/cases/compiler/exhaustiveSwitchImplicitReturn.ts(35,32): error TS7030: Not return 1; } } + + function foo6(bar: "a", a: boolean, b: boolean): number { + if (a) { + switch (bar) { + case "a": return 1; + } + } + else { + switch (b) { + case true: return -1; + case false: return 0; + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/exhaustiveSwitchImplicitReturn.js b/tests/baselines/reference/exhaustiveSwitchImplicitReturn.js index 5f8bf348c5f..9877f251993 100644 --- a/tests/baselines/reference/exhaustiveSwitchImplicitReturn.js +++ b/tests/baselines/reference/exhaustiveSwitchImplicitReturn.js @@ -39,6 +39,20 @@ function foo5(bar: "a" | "b"): number { return 1; } } + +function foo6(bar: "a", a: boolean, b: boolean): number { + if (a) { + switch (bar) { + case "a": return 1; + } + } + else { + switch (b) { + case true: return -1; + case false: return 0; + } + } +} //// [exhaustiveSwitchImplicitReturn.js] @@ -75,3 +89,16 @@ function foo5(bar) { return 1; } } +function foo6(bar, a, b) { + if (a) { + switch (bar) { + case "a": return 1; + } + } + else { + switch (b) { + case true: return -1; + case false: return 0; + } + } +} diff --git a/tests/baselines/reference/exhaustiveSwitchImplicitReturn.symbols b/tests/baselines/reference/exhaustiveSwitchImplicitReturn.symbols index d93a5228362..dcad190a9b3 100644 --- a/tests/baselines/reference/exhaustiveSwitchImplicitReturn.symbols +++ b/tests/baselines/reference/exhaustiveSwitchImplicitReturn.symbols @@ -69,3 +69,28 @@ function foo5(bar: "a" | "b"): number { } } +function foo6(bar: "a", a: boolean, b: boolean): number { +>foo6 : Symbol(foo6, Decl(exhaustiveSwitchImplicitReturn.ts, 39, 1)) +>bar : Symbol(bar, Decl(exhaustiveSwitchImplicitReturn.ts, 41, 14)) +>a : Symbol(a, Decl(exhaustiveSwitchImplicitReturn.ts, 41, 23)) +>b : Symbol(b, Decl(exhaustiveSwitchImplicitReturn.ts, 41, 35)) + + if (a) { +>a : Symbol(a, Decl(exhaustiveSwitchImplicitReturn.ts, 41, 23)) + + switch (bar) { +>bar : Symbol(bar, Decl(exhaustiveSwitchImplicitReturn.ts, 41, 14)) + + case "a": return 1; + } + } + else { + switch (b) { +>b : Symbol(b, Decl(exhaustiveSwitchImplicitReturn.ts, 41, 35)) + + case true: return -1; + case false: return 0; + } + } +} + diff --git a/tests/baselines/reference/exhaustiveSwitchImplicitReturn.types b/tests/baselines/reference/exhaustiveSwitchImplicitReturn.types index c868aa99b8f..c72b3b24477 100644 --- a/tests/baselines/reference/exhaustiveSwitchImplicitReturn.types +++ b/tests/baselines/reference/exhaustiveSwitchImplicitReturn.types @@ -85,3 +85,36 @@ function foo5(bar: "a" | "b"): number { } } +function foo6(bar: "a", a: boolean, b: boolean): number { +>foo6 : (bar: "a", a: boolean, b: boolean) => number +>bar : "a" +>a : boolean +>b : boolean + + if (a) { +>a : boolean + + switch (bar) { +>bar : "a" + + case "a": return 1; +>"a" : "a" +>1 : 1 + } + } + else { + switch (b) { +>b : boolean + + case true: return -1; +>true : true +>-1 : -1 +>1 : 1 + + case false: return 0; +>false : false +>0 : 0 + } + } +} + diff --git a/tests/baselines/reference/exhaustiveSwitchStatements1.errors.txt b/tests/baselines/reference/exhaustiveSwitchStatements1.errors.txt new file mode 100644 index 00000000000..4a54518413d --- /dev/null +++ b/tests/baselines/reference/exhaustiveSwitchStatements1.errors.txt @@ -0,0 +1,202 @@ +tests/cases/conformance/controlFlow/exhaustiveSwitchStatements1.ts(7,9): error TS7027: Unreachable code detected. + + +==== tests/cases/conformance/controlFlow/exhaustiveSwitchStatements1.ts (1 errors) ==== + function f1(x: 1 | 2): string { + if (!!true) { + switch (x) { + case 1: return 'a'; + case 2: return 'b'; + } + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + else { + throw 0; + } + } + + function f2(x: 1 | 2) { + let z: number; + switch (x) { + case 1: z = 10; break; + case 2: z = 20; break; + } + z; // Definitely assigned + } + + function f3(x: 1 | 2) { + switch (x) { + case 1: return 10; + case 2: return 20; + // Default considered reachable to allow defensive coding + default: throw new Error("Bad input"); + } + } + + // Repro from #11572 + + enum E { A, B } + + function f(e: E): number { + switch (e) { + case E.A: return 0 + case E.B: return 1 + } + } + + function g(e: E): number { + if (!true) + return -1 + else + switch (e) { + case E.A: return 0 + case E.B: return 1 + } + } + + // Repro from #12668 + + interface Square { kind: "square"; size: number; } + + interface Rectangle { kind: "rectangle"; width: number; height: number; } + + interface Circle { kind: "circle"; radius: number; } + + interface Triangle { kind: "triangle"; side: number; } + + type Shape = Square | Rectangle | Circle | Triangle; + + function area(s: Shape): number { + let area; + switch (s.kind) { + case "square": area = s.size * s.size; break; + case "rectangle": area = s.width * s.height; break; + case "circle": area = Math.PI * s.radius * s.radius; break; + case "triangle": area = Math.sqrt(3) / 4 * s.side * s.side; break; + } + return area; + } + + function areaWrapped(s: Shape): number { + let area; + area = (() => { + switch (s.kind) { + case "square": return s.size * s.size; + case "rectangle": return s.width * s.height; + case "circle": return Math.PI * s.radius * s.radius; + case "triangle": return Math.sqrt(3) / 4 * s.side * s.side; + } + })(); + return area; + } + + // Repro from #13241 + + enum MyEnum { + A, + B + } + + function thisGivesError(e: MyEnum): string { + let s: string; + switch (e) { + case MyEnum.A: s = "it was A"; break; + case MyEnum.B: s = "it was B"; break; + } + return s; + } + + function good1(e: MyEnum): string { + let s: string; + switch (e) { + case MyEnum.A: s = "it was A"; break; + case MyEnum.B: s = "it was B"; break; + default: s = "it was something else"; break; + } + return s; + } + + function good2(e: MyEnum): string { + switch (e) { + case MyEnum.A: return "it was A"; + case MyEnum.B: return "it was B"; + } + } + + // Repro from #18362 + + enum Level { + One, + Two, + } + + const doSomethingWithLevel = (level: Level) => { + let next: Level; + switch (level) { + case Level.One: + next = Level.Two; + break; + case Level.Two: + next = Level.One; + break; + } + return next; + }; + + // Repro from #20409 + + interface Square2 { + kind: "square"; + size: number; + } + + interface Circle2 { + kind: "circle"; + radius: number; + } + + type Shape2 = Square2 | Circle2; + + function withDefault(s1: Shape2, s2: Shape2): string { + switch (s1.kind) { + case "square": + return "1"; + case "circle": + switch (s2.kind) { + case "square": + return "2"; + case "circle": + return "3"; + default: + return "never"; + } + } + } + + function withoutDefault(s1: Shape2, s2: Shape2): string { + switch (s1.kind) { + case "square": + return "1"; + case "circle": + switch (s2.kind) { + case "square": + return "2"; + case "circle": + return "3"; + } + } + } + + // Repro from #20823 + + function test4(value: 1 | 2) { + let x: string; + switch (value) { + case 1: x = "one"; break; + case 2: x = "two"; break; + } + return x; + } + \ No newline at end of file diff --git a/tests/baselines/reference/exhaustiveSwitchStatements1.js b/tests/baselines/reference/exhaustiveSwitchStatements1.js new file mode 100644 index 00000000000..a39db3b8101 --- /dev/null +++ b/tests/baselines/reference/exhaustiveSwitchStatements1.js @@ -0,0 +1,437 @@ +//// [exhaustiveSwitchStatements1.ts] +function f1(x: 1 | 2): string { + if (!!true) { + switch (x) { + case 1: return 'a'; + case 2: return 'b'; + } + x; // Unreachable + } + else { + throw 0; + } +} + +function f2(x: 1 | 2) { + let z: number; + switch (x) { + case 1: z = 10; break; + case 2: z = 20; break; + } + z; // Definitely assigned +} + +function f3(x: 1 | 2) { + switch (x) { + case 1: return 10; + case 2: return 20; + // Default considered reachable to allow defensive coding + default: throw new Error("Bad input"); + } +} + +// Repro from #11572 + +enum E { A, B } + +function f(e: E): number { + switch (e) { + case E.A: return 0 + case E.B: return 1 + } +} + +function g(e: E): number { + if (!true) + return -1 + else + switch (e) { + case E.A: return 0 + case E.B: return 1 + } +} + +// Repro from #12668 + +interface Square { kind: "square"; size: number; } + +interface Rectangle { kind: "rectangle"; width: number; height: number; } + +interface Circle { kind: "circle"; radius: number; } + +interface Triangle { kind: "triangle"; side: number; } + +type Shape = Square | Rectangle | Circle | Triangle; + +function area(s: Shape): number { + let area; + switch (s.kind) { + case "square": area = s.size * s.size; break; + case "rectangle": area = s.width * s.height; break; + case "circle": area = Math.PI * s.radius * s.radius; break; + case "triangle": area = Math.sqrt(3) / 4 * s.side * s.side; break; + } + return area; +} + +function areaWrapped(s: Shape): number { + let area; + area = (() => { + switch (s.kind) { + case "square": return s.size * s.size; + case "rectangle": return s.width * s.height; + case "circle": return Math.PI * s.radius * s.radius; + case "triangle": return Math.sqrt(3) / 4 * s.side * s.side; + } + })(); + return area; +} + +// Repro from #13241 + +enum MyEnum { + A, + B +} + +function thisGivesError(e: MyEnum): string { + let s: string; + switch (e) { + case MyEnum.A: s = "it was A"; break; + case MyEnum.B: s = "it was B"; break; + } + return s; +} + +function good1(e: MyEnum): string { + let s: string; + switch (e) { + case MyEnum.A: s = "it was A"; break; + case MyEnum.B: s = "it was B"; break; + default: s = "it was something else"; break; + } + return s; +} + +function good2(e: MyEnum): string { + switch (e) { + case MyEnum.A: return "it was A"; + case MyEnum.B: return "it was B"; + } +} + +// Repro from #18362 + +enum Level { + One, + Two, +} + +const doSomethingWithLevel = (level: Level) => { + let next: Level; + switch (level) { + case Level.One: + next = Level.Two; + break; + case Level.Two: + next = Level.One; + break; + } + return next; +}; + +// Repro from #20409 + +interface Square2 { + kind: "square"; + size: number; +} + +interface Circle2 { + kind: "circle"; + radius: number; +} + +type Shape2 = Square2 | Circle2; + +function withDefault(s1: Shape2, s2: Shape2): string { + switch (s1.kind) { + case "square": + return "1"; + case "circle": + switch (s2.kind) { + case "square": + return "2"; + case "circle": + return "3"; + default: + return "never"; + } + } +} + +function withoutDefault(s1: Shape2, s2: Shape2): string { + switch (s1.kind) { + case "square": + return "1"; + case "circle": + switch (s2.kind) { + case "square": + return "2"; + case "circle": + return "3"; + } + } +} + +// Repro from #20823 + +function test4(value: 1 | 2) { + let x: string; + switch (value) { + case 1: x = "one"; break; + case 2: x = "two"; break; + } + return x; +} + + +//// [exhaustiveSwitchStatements1.js] +"use strict"; +function f1(x) { + if (!!true) { + switch (x) { + case 1: return 'a'; + case 2: return 'b'; + } + x; // Unreachable + } + else { + throw 0; + } +} +function f2(x) { + var z; + switch (x) { + case 1: + z = 10; + break; + case 2: + z = 20; + break; + } + z; // Definitely assigned +} +function f3(x) { + switch (x) { + case 1: return 10; + case 2: return 20; + // Default considered reachable to allow defensive coding + default: throw new Error("Bad input"); + } +} +// Repro from #11572 +var E; +(function (E) { + E[E["A"] = 0] = "A"; + E[E["B"] = 1] = "B"; +})(E || (E = {})); +function f(e) { + switch (e) { + case E.A: return 0; + case E.B: return 1; + } +} +function g(e) { + if (!true) + return -1; + else + switch (e) { + case E.A: return 0; + case E.B: return 1; + } +} +function area(s) { + var area; + switch (s.kind) { + case "square": + area = s.size * s.size; + break; + case "rectangle": + area = s.width * s.height; + break; + case "circle": + area = Math.PI * s.radius * s.radius; + break; + case "triangle": + area = Math.sqrt(3) / 4 * s.side * s.side; + break; + } + return area; +} +function areaWrapped(s) { + var area; + area = (function () { + switch (s.kind) { + case "square": return s.size * s.size; + case "rectangle": return s.width * s.height; + case "circle": return Math.PI * s.radius * s.radius; + case "triangle": return Math.sqrt(3) / 4 * s.side * s.side; + } + })(); + return area; +} +// Repro from #13241 +var MyEnum; +(function (MyEnum) { + MyEnum[MyEnum["A"] = 0] = "A"; + MyEnum[MyEnum["B"] = 1] = "B"; +})(MyEnum || (MyEnum = {})); +function thisGivesError(e) { + var s; + switch (e) { + case MyEnum.A: + s = "it was A"; + break; + case MyEnum.B: + s = "it was B"; + break; + } + return s; +} +function good1(e) { + var s; + switch (e) { + case MyEnum.A: + s = "it was A"; + break; + case MyEnum.B: + s = "it was B"; + break; + default: + s = "it was something else"; + break; + } + return s; +} +function good2(e) { + switch (e) { + case MyEnum.A: return "it was A"; + case MyEnum.B: return "it was B"; + } +} +// Repro from #18362 +var Level; +(function (Level) { + Level[Level["One"] = 0] = "One"; + Level[Level["Two"] = 1] = "Two"; +})(Level || (Level = {})); +var doSomethingWithLevel = function (level) { + var next; + switch (level) { + case Level.One: + next = Level.Two; + break; + case Level.Two: + next = Level.One; + break; + } + return next; +}; +function withDefault(s1, s2) { + switch (s1.kind) { + case "square": + return "1"; + case "circle": + switch (s2.kind) { + case "square": + return "2"; + case "circle": + return "3"; + default: + return "never"; + } + } +} +function withoutDefault(s1, s2) { + switch (s1.kind) { + case "square": + return "1"; + case "circle": + switch (s2.kind) { + case "square": + return "2"; + case "circle": + return "3"; + } + } +} +// Repro from #20823 +function test4(value) { + var x; + switch (value) { + case 1: + x = "one"; + break; + case 2: + x = "two"; + break; + } + return x; +} + + +//// [exhaustiveSwitchStatements1.d.ts] +declare function f1(x: 1 | 2): string; +declare function f2(x: 1 | 2): void; +declare function f3(x: 1 | 2): 10 | 20; +declare enum E { + A = 0, + B = 1 +} +declare function f(e: E): number; +declare function g(e: E): number; +interface Square { + kind: "square"; + size: number; +} +interface Rectangle { + kind: "rectangle"; + width: number; + height: number; +} +interface Circle { + kind: "circle"; + radius: number; +} +interface Triangle { + kind: "triangle"; + side: number; +} +declare type Shape = Square | Rectangle | Circle | Triangle; +declare function area(s: Shape): number; +declare function areaWrapped(s: Shape): number; +declare enum MyEnum { + A = 0, + B = 1 +} +declare function thisGivesError(e: MyEnum): string; +declare function good1(e: MyEnum): string; +declare function good2(e: MyEnum): string; +declare enum Level { + One = 0, + Two = 1 +} +declare const doSomethingWithLevel: (level: Level) => Level; +interface Square2 { + kind: "square"; + size: number; +} +interface Circle2 { + kind: "circle"; + radius: number; +} +declare type Shape2 = Square2 | Circle2; +declare function withDefault(s1: Shape2, s2: Shape2): string; +declare function withoutDefault(s1: Shape2, s2: Shape2): string; +declare function test4(value: 1 | 2): string; diff --git a/tests/baselines/reference/exhaustiveSwitchStatements1.symbols b/tests/baselines/reference/exhaustiveSwitchStatements1.symbols new file mode 100644 index 00000000000..8beb3911883 --- /dev/null +++ b/tests/baselines/reference/exhaustiveSwitchStatements1.symbols @@ -0,0 +1,503 @@ +=== tests/cases/conformance/controlFlow/exhaustiveSwitchStatements1.ts === +function f1(x: 1 | 2): string { +>f1 : Symbol(f1, Decl(exhaustiveSwitchStatements1.ts, 0, 0)) +>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 0, 12)) + + if (!!true) { + switch (x) { +>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 0, 12)) + + case 1: return 'a'; + case 2: return 'b'; + } + x; // Unreachable +>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 0, 12)) + } + else { + throw 0; + } +} + +function f2(x: 1 | 2) { +>f2 : Symbol(f2, Decl(exhaustiveSwitchStatements1.ts, 11, 1)) +>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 13, 12)) + + let z: number; +>z : Symbol(z, Decl(exhaustiveSwitchStatements1.ts, 14, 7)) + + switch (x) { +>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 13, 12)) + + case 1: z = 10; break; +>z : Symbol(z, Decl(exhaustiveSwitchStatements1.ts, 14, 7)) + + case 2: z = 20; break; +>z : Symbol(z, Decl(exhaustiveSwitchStatements1.ts, 14, 7)) + } + z; // Definitely assigned +>z : Symbol(z, Decl(exhaustiveSwitchStatements1.ts, 14, 7)) +} + +function f3(x: 1 | 2) { +>f3 : Symbol(f3, Decl(exhaustiveSwitchStatements1.ts, 20, 1)) +>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 22, 12)) + + switch (x) { +>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 22, 12)) + + case 1: return 10; + case 2: return 20; + // Default considered reachable to allow defensive coding + default: throw new Error("Bad input"); +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } +} + +// Repro from #11572 + +enum E { A, B } +>E : Symbol(E, Decl(exhaustiveSwitchStatements1.ts, 29, 1)) +>A : Symbol(E.A, Decl(exhaustiveSwitchStatements1.ts, 33, 8)) +>B : Symbol(E.B, Decl(exhaustiveSwitchStatements1.ts, 33, 11)) + +function f(e: E): number { +>f : Symbol(f, Decl(exhaustiveSwitchStatements1.ts, 33, 15)) +>e : Symbol(e, Decl(exhaustiveSwitchStatements1.ts, 35, 11)) +>E : Symbol(E, Decl(exhaustiveSwitchStatements1.ts, 29, 1)) + + switch (e) { +>e : Symbol(e, Decl(exhaustiveSwitchStatements1.ts, 35, 11)) + + case E.A: return 0 +>E.A : Symbol(E.A, Decl(exhaustiveSwitchStatements1.ts, 33, 8)) +>E : Symbol(E, Decl(exhaustiveSwitchStatements1.ts, 29, 1)) +>A : Symbol(E.A, Decl(exhaustiveSwitchStatements1.ts, 33, 8)) + + case E.B: return 1 +>E.B : Symbol(E.B, Decl(exhaustiveSwitchStatements1.ts, 33, 11)) +>E : Symbol(E, Decl(exhaustiveSwitchStatements1.ts, 29, 1)) +>B : Symbol(E.B, Decl(exhaustiveSwitchStatements1.ts, 33, 11)) + } +} + +function g(e: E): number { +>g : Symbol(g, Decl(exhaustiveSwitchStatements1.ts, 40, 1)) +>e : Symbol(e, Decl(exhaustiveSwitchStatements1.ts, 42, 11)) +>E : Symbol(E, Decl(exhaustiveSwitchStatements1.ts, 29, 1)) + + if (!true) + return -1 + else + switch (e) { +>e : Symbol(e, Decl(exhaustiveSwitchStatements1.ts, 42, 11)) + + case E.A: return 0 +>E.A : Symbol(E.A, Decl(exhaustiveSwitchStatements1.ts, 33, 8)) +>E : Symbol(E, Decl(exhaustiveSwitchStatements1.ts, 29, 1)) +>A : Symbol(E.A, Decl(exhaustiveSwitchStatements1.ts, 33, 8)) + + case E.B: return 1 +>E.B : Symbol(E.B, Decl(exhaustiveSwitchStatements1.ts, 33, 11)) +>E : Symbol(E, Decl(exhaustiveSwitchStatements1.ts, 29, 1)) +>B : Symbol(E.B, Decl(exhaustiveSwitchStatements1.ts, 33, 11)) + } +} + +// Repro from #12668 + +interface Square { kind: "square"; size: number; } +>Square : Symbol(Square, Decl(exhaustiveSwitchStatements1.ts, 50, 1)) +>kind : Symbol(Square.kind, Decl(exhaustiveSwitchStatements1.ts, 54, 18)) +>size : Symbol(Square.size, Decl(exhaustiveSwitchStatements1.ts, 54, 34)) + +interface Rectangle { kind: "rectangle"; width: number; height: number; } +>Rectangle : Symbol(Rectangle, Decl(exhaustiveSwitchStatements1.ts, 54, 50)) +>kind : Symbol(Rectangle.kind, Decl(exhaustiveSwitchStatements1.ts, 56, 21)) +>width : Symbol(Rectangle.width, Decl(exhaustiveSwitchStatements1.ts, 56, 40)) +>height : Symbol(Rectangle.height, Decl(exhaustiveSwitchStatements1.ts, 56, 55)) + +interface Circle { kind: "circle"; radius: number; } +>Circle : Symbol(Circle, Decl(exhaustiveSwitchStatements1.ts, 56, 73)) +>kind : Symbol(Circle.kind, Decl(exhaustiveSwitchStatements1.ts, 58, 18)) +>radius : Symbol(Circle.radius, Decl(exhaustiveSwitchStatements1.ts, 58, 34)) + +interface Triangle { kind: "triangle"; side: number; } +>Triangle : Symbol(Triangle, Decl(exhaustiveSwitchStatements1.ts, 58, 52)) +>kind : Symbol(Triangle.kind, Decl(exhaustiveSwitchStatements1.ts, 60, 20)) +>side : Symbol(Triangle.side, Decl(exhaustiveSwitchStatements1.ts, 60, 38)) + +type Shape = Square | Rectangle | Circle | Triangle; +>Shape : Symbol(Shape, Decl(exhaustiveSwitchStatements1.ts, 60, 54)) +>Square : Symbol(Square, Decl(exhaustiveSwitchStatements1.ts, 50, 1)) +>Rectangle : Symbol(Rectangle, Decl(exhaustiveSwitchStatements1.ts, 54, 50)) +>Circle : Symbol(Circle, Decl(exhaustiveSwitchStatements1.ts, 56, 73)) +>Triangle : Symbol(Triangle, Decl(exhaustiveSwitchStatements1.ts, 58, 52)) + +function area(s: Shape): number { +>area : Symbol(area, Decl(exhaustiveSwitchStatements1.ts, 62, 52)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 64, 14)) +>Shape : Symbol(Shape, Decl(exhaustiveSwitchStatements1.ts, 60, 54)) + + let area; +>area : Symbol(area, Decl(exhaustiveSwitchStatements1.ts, 65, 7)) + + switch (s.kind) { +>s.kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 54, 18), Decl(exhaustiveSwitchStatements1.ts, 56, 21), Decl(exhaustiveSwitchStatements1.ts, 58, 18), Decl(exhaustiveSwitchStatements1.ts, 60, 20)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 64, 14)) +>kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 54, 18), Decl(exhaustiveSwitchStatements1.ts, 56, 21), Decl(exhaustiveSwitchStatements1.ts, 58, 18), Decl(exhaustiveSwitchStatements1.ts, 60, 20)) + + case "square": area = s.size * s.size; break; +>area : Symbol(area, Decl(exhaustiveSwitchStatements1.ts, 65, 7)) +>s.size : Symbol(Square.size, Decl(exhaustiveSwitchStatements1.ts, 54, 34)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 64, 14)) +>size : Symbol(Square.size, Decl(exhaustiveSwitchStatements1.ts, 54, 34)) +>s.size : Symbol(Square.size, Decl(exhaustiveSwitchStatements1.ts, 54, 34)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 64, 14)) +>size : Symbol(Square.size, Decl(exhaustiveSwitchStatements1.ts, 54, 34)) + + case "rectangle": area = s.width * s.height; break; +>area : Symbol(area, Decl(exhaustiveSwitchStatements1.ts, 65, 7)) +>s.width : Symbol(Rectangle.width, Decl(exhaustiveSwitchStatements1.ts, 56, 40)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 64, 14)) +>width : Symbol(Rectangle.width, Decl(exhaustiveSwitchStatements1.ts, 56, 40)) +>s.height : Symbol(Rectangle.height, Decl(exhaustiveSwitchStatements1.ts, 56, 55)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 64, 14)) +>height : Symbol(Rectangle.height, Decl(exhaustiveSwitchStatements1.ts, 56, 55)) + + case "circle": area = Math.PI * s.radius * s.radius; break; +>area : Symbol(area, Decl(exhaustiveSwitchStatements1.ts, 65, 7)) +>Math.PI : Symbol(Math.PI, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>PI : Symbol(Math.PI, Decl(lib.es5.d.ts, --, --)) +>s.radius : Symbol(Circle.radius, Decl(exhaustiveSwitchStatements1.ts, 58, 34)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 64, 14)) +>radius : Symbol(Circle.radius, Decl(exhaustiveSwitchStatements1.ts, 58, 34)) +>s.radius : Symbol(Circle.radius, Decl(exhaustiveSwitchStatements1.ts, 58, 34)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 64, 14)) +>radius : Symbol(Circle.radius, Decl(exhaustiveSwitchStatements1.ts, 58, 34)) + + case "triangle": area = Math.sqrt(3) / 4 * s.side * s.side; break; +>area : Symbol(area, Decl(exhaustiveSwitchStatements1.ts, 65, 7)) +>Math.sqrt : Symbol(Math.sqrt, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>sqrt : Symbol(Math.sqrt, Decl(lib.es5.d.ts, --, --)) +>s.side : Symbol(Triangle.side, Decl(exhaustiveSwitchStatements1.ts, 60, 38)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 64, 14)) +>side : Symbol(Triangle.side, Decl(exhaustiveSwitchStatements1.ts, 60, 38)) +>s.side : Symbol(Triangle.side, Decl(exhaustiveSwitchStatements1.ts, 60, 38)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 64, 14)) +>side : Symbol(Triangle.side, Decl(exhaustiveSwitchStatements1.ts, 60, 38)) + } + return area; +>area : Symbol(area, Decl(exhaustiveSwitchStatements1.ts, 65, 7)) +} + +function areaWrapped(s: Shape): number { +>areaWrapped : Symbol(areaWrapped, Decl(exhaustiveSwitchStatements1.ts, 73, 1)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 75, 21)) +>Shape : Symbol(Shape, Decl(exhaustiveSwitchStatements1.ts, 60, 54)) + + let area; +>area : Symbol(area, Decl(exhaustiveSwitchStatements1.ts, 76, 7)) + + area = (() => { +>area : Symbol(area, Decl(exhaustiveSwitchStatements1.ts, 76, 7)) + + switch (s.kind) { +>s.kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 54, 18), Decl(exhaustiveSwitchStatements1.ts, 56, 21), Decl(exhaustiveSwitchStatements1.ts, 58, 18), Decl(exhaustiveSwitchStatements1.ts, 60, 20)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 75, 21)) +>kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 54, 18), Decl(exhaustiveSwitchStatements1.ts, 56, 21), Decl(exhaustiveSwitchStatements1.ts, 58, 18), Decl(exhaustiveSwitchStatements1.ts, 60, 20)) + + case "square": return s.size * s.size; +>s.size : Symbol(Square.size, Decl(exhaustiveSwitchStatements1.ts, 54, 34)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 75, 21)) +>size : Symbol(Square.size, Decl(exhaustiveSwitchStatements1.ts, 54, 34)) +>s.size : Symbol(Square.size, Decl(exhaustiveSwitchStatements1.ts, 54, 34)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 75, 21)) +>size : Symbol(Square.size, Decl(exhaustiveSwitchStatements1.ts, 54, 34)) + + case "rectangle": return s.width * s.height; +>s.width : Symbol(Rectangle.width, Decl(exhaustiveSwitchStatements1.ts, 56, 40)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 75, 21)) +>width : Symbol(Rectangle.width, Decl(exhaustiveSwitchStatements1.ts, 56, 40)) +>s.height : Symbol(Rectangle.height, Decl(exhaustiveSwitchStatements1.ts, 56, 55)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 75, 21)) +>height : Symbol(Rectangle.height, Decl(exhaustiveSwitchStatements1.ts, 56, 55)) + + case "circle": return Math.PI * s.radius * s.radius; +>Math.PI : Symbol(Math.PI, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>PI : Symbol(Math.PI, Decl(lib.es5.d.ts, --, --)) +>s.radius : Symbol(Circle.radius, Decl(exhaustiveSwitchStatements1.ts, 58, 34)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 75, 21)) +>radius : Symbol(Circle.radius, Decl(exhaustiveSwitchStatements1.ts, 58, 34)) +>s.radius : Symbol(Circle.radius, Decl(exhaustiveSwitchStatements1.ts, 58, 34)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 75, 21)) +>radius : Symbol(Circle.radius, Decl(exhaustiveSwitchStatements1.ts, 58, 34)) + + case "triangle": return Math.sqrt(3) / 4 * s.side * s.side; +>Math.sqrt : Symbol(Math.sqrt, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>sqrt : Symbol(Math.sqrt, Decl(lib.es5.d.ts, --, --)) +>s.side : Symbol(Triangle.side, Decl(exhaustiveSwitchStatements1.ts, 60, 38)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 75, 21)) +>side : Symbol(Triangle.side, Decl(exhaustiveSwitchStatements1.ts, 60, 38)) +>s.side : Symbol(Triangle.side, Decl(exhaustiveSwitchStatements1.ts, 60, 38)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 75, 21)) +>side : Symbol(Triangle.side, Decl(exhaustiveSwitchStatements1.ts, 60, 38)) + } + })(); + return area; +>area : Symbol(area, Decl(exhaustiveSwitchStatements1.ts, 76, 7)) +} + +// Repro from #13241 + +enum MyEnum { +>MyEnum : Symbol(MyEnum, Decl(exhaustiveSwitchStatements1.ts, 86, 1)) + + A, +>A : Symbol(MyEnum.A, Decl(exhaustiveSwitchStatements1.ts, 90, 13)) + + B +>B : Symbol(MyEnum.B, Decl(exhaustiveSwitchStatements1.ts, 91, 3)) +} + +function thisGivesError(e: MyEnum): string { +>thisGivesError : Symbol(thisGivesError, Decl(exhaustiveSwitchStatements1.ts, 93, 1)) +>e : Symbol(e, Decl(exhaustiveSwitchStatements1.ts, 95, 24)) +>MyEnum : Symbol(MyEnum, Decl(exhaustiveSwitchStatements1.ts, 86, 1)) + + let s: string; +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 96, 4)) + + switch (e) { +>e : Symbol(e, Decl(exhaustiveSwitchStatements1.ts, 95, 24)) + + case MyEnum.A: s = "it was A"; break; +>MyEnum.A : Symbol(MyEnum.A, Decl(exhaustiveSwitchStatements1.ts, 90, 13)) +>MyEnum : Symbol(MyEnum, Decl(exhaustiveSwitchStatements1.ts, 86, 1)) +>A : Symbol(MyEnum.A, Decl(exhaustiveSwitchStatements1.ts, 90, 13)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 96, 4)) + + case MyEnum.B: s = "it was B"; break; +>MyEnum.B : Symbol(MyEnum.B, Decl(exhaustiveSwitchStatements1.ts, 91, 3)) +>MyEnum : Symbol(MyEnum, Decl(exhaustiveSwitchStatements1.ts, 86, 1)) +>B : Symbol(MyEnum.B, Decl(exhaustiveSwitchStatements1.ts, 91, 3)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 96, 4)) + } + return s; +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 96, 4)) +} + +function good1(e: MyEnum): string { +>good1 : Symbol(good1, Decl(exhaustiveSwitchStatements1.ts, 102, 1)) +>e : Symbol(e, Decl(exhaustiveSwitchStatements1.ts, 104, 15)) +>MyEnum : Symbol(MyEnum, Decl(exhaustiveSwitchStatements1.ts, 86, 1)) + + let s: string; +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 105, 4)) + + switch (e) { +>e : Symbol(e, Decl(exhaustiveSwitchStatements1.ts, 104, 15)) + + case MyEnum.A: s = "it was A"; break; +>MyEnum.A : Symbol(MyEnum.A, Decl(exhaustiveSwitchStatements1.ts, 90, 13)) +>MyEnum : Symbol(MyEnum, Decl(exhaustiveSwitchStatements1.ts, 86, 1)) +>A : Symbol(MyEnum.A, Decl(exhaustiveSwitchStatements1.ts, 90, 13)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 105, 4)) + + case MyEnum.B: s = "it was B"; break; +>MyEnum.B : Symbol(MyEnum.B, Decl(exhaustiveSwitchStatements1.ts, 91, 3)) +>MyEnum : Symbol(MyEnum, Decl(exhaustiveSwitchStatements1.ts, 86, 1)) +>B : Symbol(MyEnum.B, Decl(exhaustiveSwitchStatements1.ts, 91, 3)) +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 105, 4)) + + default: s = "it was something else"; break; +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 105, 4)) + } + return s; +>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 105, 4)) +} + +function good2(e: MyEnum): string { +>good2 : Symbol(good2, Decl(exhaustiveSwitchStatements1.ts, 112, 1)) +>e : Symbol(e, Decl(exhaustiveSwitchStatements1.ts, 114, 15)) +>MyEnum : Symbol(MyEnum, Decl(exhaustiveSwitchStatements1.ts, 86, 1)) + + switch (e) { +>e : Symbol(e, Decl(exhaustiveSwitchStatements1.ts, 114, 15)) + + case MyEnum.A: return "it was A"; +>MyEnum.A : Symbol(MyEnum.A, Decl(exhaustiveSwitchStatements1.ts, 90, 13)) +>MyEnum : Symbol(MyEnum, Decl(exhaustiveSwitchStatements1.ts, 86, 1)) +>A : Symbol(MyEnum.A, Decl(exhaustiveSwitchStatements1.ts, 90, 13)) + + case MyEnum.B: return "it was B"; +>MyEnum.B : Symbol(MyEnum.B, Decl(exhaustiveSwitchStatements1.ts, 91, 3)) +>MyEnum : Symbol(MyEnum, Decl(exhaustiveSwitchStatements1.ts, 86, 1)) +>B : Symbol(MyEnum.B, Decl(exhaustiveSwitchStatements1.ts, 91, 3)) + } +} + +// Repro from #18362 + +enum Level { +>Level : Symbol(Level, Decl(exhaustiveSwitchStatements1.ts, 119, 1)) + + One, +>One : Symbol(Level.One, Decl(exhaustiveSwitchStatements1.ts, 123, 12)) + + Two, +>Two : Symbol(Level.Two, Decl(exhaustiveSwitchStatements1.ts, 124, 6)) +} + +const doSomethingWithLevel = (level: Level) => { +>doSomethingWithLevel : Symbol(doSomethingWithLevel, Decl(exhaustiveSwitchStatements1.ts, 128, 5)) +>level : Symbol(level, Decl(exhaustiveSwitchStatements1.ts, 128, 30)) +>Level : Symbol(Level, Decl(exhaustiveSwitchStatements1.ts, 119, 1)) + + let next: Level; +>next : Symbol(next, Decl(exhaustiveSwitchStatements1.ts, 129, 5)) +>Level : Symbol(Level, Decl(exhaustiveSwitchStatements1.ts, 119, 1)) + + switch (level) { +>level : Symbol(level, Decl(exhaustiveSwitchStatements1.ts, 128, 30)) + + case Level.One: +>Level.One : Symbol(Level.One, Decl(exhaustiveSwitchStatements1.ts, 123, 12)) +>Level : Symbol(Level, Decl(exhaustiveSwitchStatements1.ts, 119, 1)) +>One : Symbol(Level.One, Decl(exhaustiveSwitchStatements1.ts, 123, 12)) + + next = Level.Two; +>next : Symbol(next, Decl(exhaustiveSwitchStatements1.ts, 129, 5)) +>Level.Two : Symbol(Level.Two, Decl(exhaustiveSwitchStatements1.ts, 124, 6)) +>Level : Symbol(Level, Decl(exhaustiveSwitchStatements1.ts, 119, 1)) +>Two : Symbol(Level.Two, Decl(exhaustiveSwitchStatements1.ts, 124, 6)) + + break; + case Level.Two: +>Level.Two : Symbol(Level.Two, Decl(exhaustiveSwitchStatements1.ts, 124, 6)) +>Level : Symbol(Level, Decl(exhaustiveSwitchStatements1.ts, 119, 1)) +>Two : Symbol(Level.Two, Decl(exhaustiveSwitchStatements1.ts, 124, 6)) + + next = Level.One; +>next : Symbol(next, Decl(exhaustiveSwitchStatements1.ts, 129, 5)) +>Level.One : Symbol(Level.One, Decl(exhaustiveSwitchStatements1.ts, 123, 12)) +>Level : Symbol(Level, Decl(exhaustiveSwitchStatements1.ts, 119, 1)) +>One : Symbol(Level.One, Decl(exhaustiveSwitchStatements1.ts, 123, 12)) + + break; + } + return next; +>next : Symbol(next, Decl(exhaustiveSwitchStatements1.ts, 129, 5)) + +}; + +// Repro from #20409 + +interface Square2 { +>Square2 : Symbol(Square2, Decl(exhaustiveSwitchStatements1.ts, 139, 2)) + + kind: "square"; +>kind : Symbol(Square2.kind, Decl(exhaustiveSwitchStatements1.ts, 143, 19)) + + size: number; +>size : Symbol(Square2.size, Decl(exhaustiveSwitchStatements1.ts, 144, 19)) +} + +interface Circle2 { +>Circle2 : Symbol(Circle2, Decl(exhaustiveSwitchStatements1.ts, 146, 1)) + + kind: "circle"; +>kind : Symbol(Circle2.kind, Decl(exhaustiveSwitchStatements1.ts, 148, 19)) + + radius: number; +>radius : Symbol(Circle2.radius, Decl(exhaustiveSwitchStatements1.ts, 149, 19)) +} + +type Shape2 = Square2 | Circle2; +>Shape2 : Symbol(Shape2, Decl(exhaustiveSwitchStatements1.ts, 151, 1)) +>Square2 : Symbol(Square2, Decl(exhaustiveSwitchStatements1.ts, 139, 2)) +>Circle2 : Symbol(Circle2, Decl(exhaustiveSwitchStatements1.ts, 146, 1)) + +function withDefault(s1: Shape2, s2: Shape2): string { +>withDefault : Symbol(withDefault, Decl(exhaustiveSwitchStatements1.ts, 153, 32)) +>s1 : Symbol(s1, Decl(exhaustiveSwitchStatements1.ts, 155, 21)) +>Shape2 : Symbol(Shape2, Decl(exhaustiveSwitchStatements1.ts, 151, 1)) +>s2 : Symbol(s2, Decl(exhaustiveSwitchStatements1.ts, 155, 32)) +>Shape2 : Symbol(Shape2, Decl(exhaustiveSwitchStatements1.ts, 151, 1)) + + switch (s1.kind) { +>s1.kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 143, 19), Decl(exhaustiveSwitchStatements1.ts, 148, 19)) +>s1 : Symbol(s1, Decl(exhaustiveSwitchStatements1.ts, 155, 21)) +>kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 143, 19), Decl(exhaustiveSwitchStatements1.ts, 148, 19)) + + case "square": + return "1"; + case "circle": + switch (s2.kind) { +>s2.kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 143, 19), Decl(exhaustiveSwitchStatements1.ts, 148, 19)) +>s2 : Symbol(s2, Decl(exhaustiveSwitchStatements1.ts, 155, 32)) +>kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 143, 19), Decl(exhaustiveSwitchStatements1.ts, 148, 19)) + + case "square": + return "2"; + case "circle": + return "3"; + default: + return "never"; + } + } +} + +function withoutDefault(s1: Shape2, s2: Shape2): string { +>withoutDefault : Symbol(withoutDefault, Decl(exhaustiveSwitchStatements1.ts, 169, 1)) +>s1 : Symbol(s1, Decl(exhaustiveSwitchStatements1.ts, 171, 24)) +>Shape2 : Symbol(Shape2, Decl(exhaustiveSwitchStatements1.ts, 151, 1)) +>s2 : Symbol(s2, Decl(exhaustiveSwitchStatements1.ts, 171, 35)) +>Shape2 : Symbol(Shape2, Decl(exhaustiveSwitchStatements1.ts, 151, 1)) + + switch (s1.kind) { +>s1.kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 143, 19), Decl(exhaustiveSwitchStatements1.ts, 148, 19)) +>s1 : Symbol(s1, Decl(exhaustiveSwitchStatements1.ts, 171, 24)) +>kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 143, 19), Decl(exhaustiveSwitchStatements1.ts, 148, 19)) + + case "square": + return "1"; + case "circle": + switch (s2.kind) { +>s2.kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 143, 19), Decl(exhaustiveSwitchStatements1.ts, 148, 19)) +>s2 : Symbol(s2, Decl(exhaustiveSwitchStatements1.ts, 171, 35)) +>kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 143, 19), Decl(exhaustiveSwitchStatements1.ts, 148, 19)) + + case "square": + return "2"; + case "circle": + return "3"; + } + } +} + +// Repro from #20823 + +function test4(value: 1 | 2) { +>test4 : Symbol(test4, Decl(exhaustiveSwitchStatements1.ts, 183, 1)) +>value : Symbol(value, Decl(exhaustiveSwitchStatements1.ts, 187, 15)) + + let x: string; +>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 188, 7)) + + switch (value) { +>value : Symbol(value, Decl(exhaustiveSwitchStatements1.ts, 187, 15)) + + case 1: x = "one"; break; +>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 188, 7)) + + case 2: x = "two"; break; +>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 188, 7)) + } + return x; +>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 188, 7)) +} + diff --git a/tests/baselines/reference/exhaustiveSwitchStatements1.types b/tests/baselines/reference/exhaustiveSwitchStatements1.types new file mode 100644 index 00000000000..04a9bf531ce --- /dev/null +++ b/tests/baselines/reference/exhaustiveSwitchStatements1.types @@ -0,0 +1,595 @@ +=== tests/cases/conformance/controlFlow/exhaustiveSwitchStatements1.ts === +function f1(x: 1 | 2): string { +>f1 : (x: 1 | 2) => string +>x : 1 | 2 + + if (!!true) { +>!!true : true +>!true : false +>true : true + + switch (x) { +>x : 1 | 2 + + case 1: return 'a'; +>1 : 1 +>'a' : "a" + + case 2: return 'b'; +>2 : 2 +>'b' : "b" + } + x; // Unreachable +>x : never + } + else { + throw 0; +>0 : 0 + } +} + +function f2(x: 1 | 2) { +>f2 : (x: 1 | 2) => void +>x : 1 | 2 + + let z: number; +>z : number + + switch (x) { +>x : 1 | 2 + + case 1: z = 10; break; +>1 : 1 +>z = 10 : 10 +>z : number +>10 : 10 + + case 2: z = 20; break; +>2 : 2 +>z = 20 : 20 +>z : number +>20 : 20 + } + z; // Definitely assigned +>z : number +} + +function f3(x: 1 | 2) { +>f3 : (x: 1 | 2) => 10 | 20 +>x : 1 | 2 + + switch (x) { +>x : 1 | 2 + + case 1: return 10; +>1 : 1 +>10 : 10 + + case 2: return 20; +>2 : 2 +>20 : 20 + + // Default considered reachable to allow defensive coding + default: throw new Error("Bad input"); +>new Error("Bad input") : Error +>Error : ErrorConstructor +>"Bad input" : "Bad input" + } +} + +// Repro from #11572 + +enum E { A, B } +>E : E +>A : E.A +>B : E.B + +function f(e: E): number { +>f : (e: E) => number +>e : E + + switch (e) { +>e : E + + case E.A: return 0 +>E.A : E.A +>E : typeof E +>A : E.A +>0 : 0 + + case E.B: return 1 +>E.B : E.B +>E : typeof E +>B : E.B +>1 : 1 + } +} + +function g(e: E): number { +>g : (e: E) => number +>e : E + + if (!true) +>!true : false +>true : true + + return -1 +>-1 : -1 +>1 : 1 + + else + switch (e) { +>e : E + + case E.A: return 0 +>E.A : E.A +>E : typeof E +>A : E.A +>0 : 0 + + case E.B: return 1 +>E.B : E.B +>E : typeof E +>B : E.B +>1 : 1 + } +} + +// Repro from #12668 + +interface Square { kind: "square"; size: number; } +>kind : "square" +>size : number + +interface Rectangle { kind: "rectangle"; width: number; height: number; } +>kind : "rectangle" +>width : number +>height : number + +interface Circle { kind: "circle"; radius: number; } +>kind : "circle" +>radius : number + +interface Triangle { kind: "triangle"; side: number; } +>kind : "triangle" +>side : number + +type Shape = Square | Rectangle | Circle | Triangle; +>Shape : Shape + +function area(s: Shape): number { +>area : (s: Shape) => number +>s : Shape + + let area; +>area : any + + switch (s.kind) { +>s.kind : "square" | "rectangle" | "circle" | "triangle" +>s : Shape +>kind : "square" | "rectangle" | "circle" | "triangle" + + case "square": area = s.size * s.size; break; +>"square" : "square" +>area = s.size * s.size : number +>area : any +>s.size * s.size : number +>s.size : number +>s : Square +>size : number +>s.size : number +>s : Square +>size : number + + case "rectangle": area = s.width * s.height; break; +>"rectangle" : "rectangle" +>area = s.width * s.height : number +>area : any +>s.width * s.height : number +>s.width : number +>s : Rectangle +>width : number +>s.height : number +>s : Rectangle +>height : number + + case "circle": area = Math.PI * s.radius * s.radius; break; +>"circle" : "circle" +>area = Math.PI * s.radius * s.radius : number +>area : any +>Math.PI * s.radius * s.radius : number +>Math.PI * s.radius : number +>Math.PI : number +>Math : Math +>PI : number +>s.radius : number +>s : Circle +>radius : number +>s.radius : number +>s : Circle +>radius : number + + case "triangle": area = Math.sqrt(3) / 4 * s.side * s.side; break; +>"triangle" : "triangle" +>area = Math.sqrt(3) / 4 * s.side * s.side : number +>area : any +>Math.sqrt(3) / 4 * s.side * s.side : number +>Math.sqrt(3) / 4 * s.side : number +>Math.sqrt(3) / 4 : number +>Math.sqrt(3) : number +>Math.sqrt : (x: number) => number +>Math : Math +>sqrt : (x: number) => number +>3 : 3 +>4 : 4 +>s.side : number +>s : Triangle +>side : number +>s.side : number +>s : Triangle +>side : number + } + return area; +>area : number +} + +function areaWrapped(s: Shape): number { +>areaWrapped : (s: Shape) => number +>s : Shape + + let area; +>area : any + + area = (() => { +>area = (() => { switch (s.kind) { case "square": return s.size * s.size; case "rectangle": return s.width * s.height; case "circle": return Math.PI * s.radius * s.radius; case "triangle": return Math.sqrt(3) / 4 * s.side * s.side; } })() : number +>area : any +>(() => { switch (s.kind) { case "square": return s.size * s.size; case "rectangle": return s.width * s.height; case "circle": return Math.PI * s.radius * s.radius; case "triangle": return Math.sqrt(3) / 4 * s.side * s.side; } })() : number +>(() => { switch (s.kind) { case "square": return s.size * s.size; case "rectangle": return s.width * s.height; case "circle": return Math.PI * s.radius * s.radius; case "triangle": return Math.sqrt(3) / 4 * s.side * s.side; } }) : () => number +>() => { switch (s.kind) { case "square": return s.size * s.size; case "rectangle": return s.width * s.height; case "circle": return Math.PI * s.radius * s.radius; case "triangle": return Math.sqrt(3) / 4 * s.side * s.side; } } : () => number + + switch (s.kind) { +>s.kind : "square" | "rectangle" | "circle" | "triangle" +>s : Shape +>kind : "square" | "rectangle" | "circle" | "triangle" + + case "square": return s.size * s.size; +>"square" : "square" +>s.size * s.size : number +>s.size : number +>s : Square +>size : number +>s.size : number +>s : Square +>size : number + + case "rectangle": return s.width * s.height; +>"rectangle" : "rectangle" +>s.width * s.height : number +>s.width : number +>s : Rectangle +>width : number +>s.height : number +>s : Rectangle +>height : number + + case "circle": return Math.PI * s.radius * s.radius; +>"circle" : "circle" +>Math.PI * s.radius * s.radius : number +>Math.PI * s.radius : number +>Math.PI : number +>Math : Math +>PI : number +>s.radius : number +>s : Circle +>radius : number +>s.radius : number +>s : Circle +>radius : number + + case "triangle": return Math.sqrt(3) / 4 * s.side * s.side; +>"triangle" : "triangle" +>Math.sqrt(3) / 4 * s.side * s.side : number +>Math.sqrt(3) / 4 * s.side : number +>Math.sqrt(3) / 4 : number +>Math.sqrt(3) : number +>Math.sqrt : (x: number) => number +>Math : Math +>sqrt : (x: number) => number +>3 : 3 +>4 : 4 +>s.side : number +>s : Triangle +>side : number +>s.side : number +>s : Triangle +>side : number + } + })(); + return area; +>area : number +} + +// Repro from #13241 + +enum MyEnum { +>MyEnum : MyEnum + + A, +>A : MyEnum.A + + B +>B : MyEnum.B +} + +function thisGivesError(e: MyEnum): string { +>thisGivesError : (e: MyEnum) => string +>e : MyEnum + + let s: string; +>s : string + + switch (e) { +>e : MyEnum + + case MyEnum.A: s = "it was A"; break; +>MyEnum.A : MyEnum.A +>MyEnum : typeof MyEnum +>A : MyEnum.A +>s = "it was A" : "it was A" +>s : string +>"it was A" : "it was A" + + case MyEnum.B: s = "it was B"; break; +>MyEnum.B : MyEnum.B +>MyEnum : typeof MyEnum +>B : MyEnum.B +>s = "it was B" : "it was B" +>s : string +>"it was B" : "it was B" + } + return s; +>s : string +} + +function good1(e: MyEnum): string { +>good1 : (e: MyEnum) => string +>e : MyEnum + + let s: string; +>s : string + + switch (e) { +>e : MyEnum + + case MyEnum.A: s = "it was A"; break; +>MyEnum.A : MyEnum.A +>MyEnum : typeof MyEnum +>A : MyEnum.A +>s = "it was A" : "it was A" +>s : string +>"it was A" : "it was A" + + case MyEnum.B: s = "it was B"; break; +>MyEnum.B : MyEnum.B +>MyEnum : typeof MyEnum +>B : MyEnum.B +>s = "it was B" : "it was B" +>s : string +>"it was B" : "it was B" + + default: s = "it was something else"; break; +>s = "it was something else" : "it was something else" +>s : string +>"it was something else" : "it was something else" + } + return s; +>s : string +} + +function good2(e: MyEnum): string { +>good2 : (e: MyEnum) => string +>e : MyEnum + + switch (e) { +>e : MyEnum + + case MyEnum.A: return "it was A"; +>MyEnum.A : MyEnum.A +>MyEnum : typeof MyEnum +>A : MyEnum.A +>"it was A" : "it was A" + + case MyEnum.B: return "it was B"; +>MyEnum.B : MyEnum.B +>MyEnum : typeof MyEnum +>B : MyEnum.B +>"it was B" : "it was B" + } +} + +// Repro from #18362 + +enum Level { +>Level : Level + + One, +>One : Level.One + + Two, +>Two : Level.Two +} + +const doSomethingWithLevel = (level: Level) => { +>doSomethingWithLevel : (level: Level) => Level +>(level: Level) => { let next: Level; switch (level) { case Level.One: next = Level.Two; break; case Level.Two: next = Level.One; break; } return next;} : (level: Level) => Level +>level : Level + + let next: Level; +>next : Level + + switch (level) { +>level : Level + + case Level.One: +>Level.One : Level.One +>Level : typeof Level +>One : Level.One + + next = Level.Two; +>next = Level.Two : Level.Two +>next : Level +>Level.Two : Level.Two +>Level : typeof Level +>Two : Level.Two + + break; + case Level.Two: +>Level.Two : Level.Two +>Level : typeof Level +>Two : Level.Two + + next = Level.One; +>next = Level.One : Level.One +>next : Level +>Level.One : Level.One +>Level : typeof Level +>One : Level.One + + break; + } + return next; +>next : Level + +}; + +// Repro from #20409 + +interface Square2 { + kind: "square"; +>kind : "square" + + size: number; +>size : number +} + +interface Circle2 { + kind: "circle"; +>kind : "circle" + + radius: number; +>radius : number +} + +type Shape2 = Square2 | Circle2; +>Shape2 : Shape2 + +function withDefault(s1: Shape2, s2: Shape2): string { +>withDefault : (s1: Shape2, s2: Shape2) => string +>s1 : Shape2 +>s2 : Shape2 + + switch (s1.kind) { +>s1.kind : "square" | "circle" +>s1 : Shape2 +>kind : "square" | "circle" + + case "square": +>"square" : "square" + + return "1"; +>"1" : "1" + + case "circle": +>"circle" : "circle" + + switch (s2.kind) { +>s2.kind : "square" | "circle" +>s2 : Shape2 +>kind : "square" | "circle" + + case "square": +>"square" : "square" + + return "2"; +>"2" : "2" + + case "circle": +>"circle" : "circle" + + return "3"; +>"3" : "3" + + default: + return "never"; +>"never" : "never" + } + } +} + +function withoutDefault(s1: Shape2, s2: Shape2): string { +>withoutDefault : (s1: Shape2, s2: Shape2) => string +>s1 : Shape2 +>s2 : Shape2 + + switch (s1.kind) { +>s1.kind : "square" | "circle" +>s1 : Shape2 +>kind : "square" | "circle" + + case "square": +>"square" : "square" + + return "1"; +>"1" : "1" + + case "circle": +>"circle" : "circle" + + switch (s2.kind) { +>s2.kind : "square" | "circle" +>s2 : Shape2 +>kind : "square" | "circle" + + case "square": +>"square" : "square" + + return "2"; +>"2" : "2" + + case "circle": +>"circle" : "circle" + + return "3"; +>"3" : "3" + } + } +} + +// Repro from #20823 + +function test4(value: 1 | 2) { +>test4 : (value: 1 | 2) => string +>value : 1 | 2 + + let x: string; +>x : string + + switch (value) { +>value : 1 | 2 + + case 1: x = "one"; break; +>1 : 1 +>x = "one" : "one" +>x : string +>"one" : "one" + + case 2: x = "two"; break; +>2 : 2 +>x = "two" : "two" +>x : string +>"two" : "two" + } + return x; +>x : string +} + diff --git a/tests/baselines/reference/extendAndImplementTheSameBaseType2.errors.txt b/tests/baselines/reference/extendAndImplementTheSameBaseType2.errors.txt index 799fc7bb8b0..e23d9ebd282 100644 --- a/tests/baselines/reference/extendAndImplementTheSameBaseType2.errors.txt +++ b/tests/baselines/reference/extendAndImplementTheSameBaseType2.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/extendAndImplementTheSameBaseType2.ts(7,7): error TS2720: Class 'D' incorrectly implements class 'C'. Did you mean to extend 'C' and inherit its members as a subclass? - Types of property 'bar' are incompatible. - Type '() => string' is not assignable to type '() => number'. - Type 'string' is not assignable to type 'number'. + The types returned by 'bar()' are incompatible between these types. + Type 'string' is not assignable to type 'number'. tests/cases/compiler/extendAndImplementTheSameBaseType2.ts(12,5): error TS2322: Type 'number' is not assignable to type 'string'. tests/cases/compiler/extendAndImplementTheSameBaseType2.ts(16,5): error TS2322: Type 'string' is not assignable to type 'number'. @@ -16,9 +15,8 @@ tests/cases/compiler/extendAndImplementTheSameBaseType2.ts(16,5): error TS2322: class D extends C implements C { ~ !!! error TS2720: Class 'D' incorrectly implements class 'C'. Did you mean to extend 'C' and inherit its members as a subclass? -!!! error TS2720: Types of property 'bar' are incompatible. -!!! error TS2720: Type '() => string' is not assignable to type '() => number'. -!!! error TS2720: Type 'string' is not assignable to type 'number'. +!!! error TS2720: The types returned by 'bar()' are incompatible between these types. +!!! error TS2720: Type 'string' is not assignable to type 'number'. baz() { } } diff --git a/tests/baselines/reference/for-of39.errors.txt b/tests/baselines/reference/for-of39.errors.txt index a36c1c28a8c..3ecdc46bcfc 100644 --- a/tests/baselines/reference/for-of39.errors.txt +++ b/tests/baselines/reference/for-of39.errors.txt @@ -1,18 +1,14 @@ tests/cases/conformance/es6/for-ofStatements/for-of39.ts(1,11): error TS2769: No overload matches this call. Overload 1 of 3, '(iterable: Iterable): Map', gave the following error. Argument of type '([string, number] | [string, true])[]' is not assignable to parameter of type 'Iterable'. - Types of property '[Symbol.iterator]' are incompatible. - Type '() => IterableIterator<[string, number] | [string, true]>' is not assignable to type '() => Iterator'. - Type 'IterableIterator<[string, number] | [string, true]>' is not assignable to type 'Iterator'. - Types of property 'next' are incompatible. - Type '(...args: [] | [undefined]) => IteratorResult<[string, number] | [string, true], any>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult'. - Type 'IteratorResult<[string, number] | [string, true], any>' is not assignable to type 'IteratorResult'. - Type 'IteratorYieldResult<[string, number] | [string, true]>' is not assignable to type 'IteratorResult'. - Type 'IteratorYieldResult<[string, number] | [string, true]>' is not assignable to type 'IteratorYieldResult'. - Type '[string, number] | [string, true]' is not assignable to type 'readonly [string, boolean]'. - Type '[string, number]' is not assignable to type 'readonly [string, boolean]'. - Types of property '1' are incompatible. - Type 'number' is not assignable to type 'boolean'. + The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types. + Type 'IteratorResult<[string, number] | [string, true], any>' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult<[string, number] | [string, true]>' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult<[string, number] | [string, true]>' is not assignable to type 'IteratorYieldResult'. + Type '[string, number] | [string, true]' is not assignable to type 'readonly [string, boolean]'. + Type '[string, number]' is not assignable to type 'readonly [string, boolean]'. + Types of property '1' are incompatible. + Type 'number' is not assignable to type 'boolean'. Overload 2 of 3, '(entries?: readonly (readonly [string, boolean])[]): Map', gave the following error. Type 'number' is not assignable to type 'boolean'. @@ -23,18 +19,14 @@ tests/cases/conformance/es6/for-ofStatements/for-of39.ts(1,11): error TS2769: No !!! error TS2769: No overload matches this call. !!! error TS2769: Overload 1 of 3, '(iterable: Iterable): Map', gave the following error. !!! error TS2769: Argument of type '([string, number] | [string, true])[]' is not assignable to parameter of type 'Iterable'. -!!! error TS2769: Types of property '[Symbol.iterator]' are incompatible. -!!! error TS2769: Type '() => IterableIterator<[string, number] | [string, true]>' is not assignable to type '() => Iterator'. -!!! error TS2769: Type 'IterableIterator<[string, number] | [string, true]>' is not assignable to type 'Iterator'. -!!! error TS2769: Types of property 'next' are incompatible. -!!! error TS2769: Type '(...args: [] | [undefined]) => IteratorResult<[string, number] | [string, true], any>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult'. -!!! error TS2769: Type 'IteratorResult<[string, number] | [string, true], any>' is not assignable to type 'IteratorResult'. -!!! error TS2769: Type 'IteratorYieldResult<[string, number] | [string, true]>' is not assignable to type 'IteratorResult'. -!!! error TS2769: Type 'IteratorYieldResult<[string, number] | [string, true]>' is not assignable to type 'IteratorYieldResult'. -!!! error TS2769: Type '[string, number] | [string, true]' is not assignable to type 'readonly [string, boolean]'. -!!! error TS2769: Type '[string, number]' is not assignable to type 'readonly [string, boolean]'. -!!! error TS2769: Types of property '1' are incompatible. -!!! error TS2769: Type 'number' is not assignable to type 'boolean'. +!!! error TS2769: The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types. +!!! error TS2769: Type 'IteratorResult<[string, number] | [string, true], any>' is not assignable to type 'IteratorResult'. +!!! error TS2769: Type 'IteratorYieldResult<[string, number] | [string, true]>' is not assignable to type 'IteratorResult'. +!!! error TS2769: Type 'IteratorYieldResult<[string, number] | [string, true]>' is not assignable to type 'IteratorYieldResult'. +!!! error TS2769: Type '[string, number] | [string, true]' is not assignable to type 'readonly [string, boolean]'. +!!! error TS2769: Type '[string, number]' is not assignable to type 'readonly [string, boolean]'. +!!! error TS2769: Types of property '1' are incompatible. +!!! error TS2769: Type 'number' is not assignable to type 'boolean'. !!! error TS2769: Overload 2 of 3, '(entries?: readonly (readonly [string, boolean])[]): Map', gave the following error. !!! error TS2769: Type 'number' is not assignable to type 'boolean'. for (var [k, v] of map) { diff --git a/tests/baselines/reference/generatorTypeCheck25.errors.txt b/tests/baselines/reference/generatorTypeCheck25.errors.txt index 365a19dfdd7..e37f1304963 100644 --- a/tests/baselines/reference/generatorTypeCheck25.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck25.errors.txt @@ -1,15 +1,11 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck25.ts(4,5): error TS2322: Type '() => Generator' is not assignable to type '() => Iterable'. - Type 'Generator' is not assignable to type 'Iterable'. - Types of property '[Symbol.iterator]' are incompatible. - Type '() => Generator' is not assignable to type '() => Iterator'. - Type 'Generator' is not assignable to type 'Iterator'. - Types of property 'next' are incompatible. - Type '(...args: [] | [undefined]) => IteratorResult' is not assignable to type '(...args: [] | [undefined]) => IteratorResult'. - Type 'IteratorResult' is not assignable to type 'IteratorResult'. - Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. - Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. - Type 'Bar | Baz' is not assignable to type 'Foo'. - Property 'x' is missing in type 'Baz' but required in type 'Foo'. + Call signature return types 'Generator' and 'Iterable' are incompatible. + The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types. + Type 'IteratorResult' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. + Type 'Bar | Baz' is not assignable to type 'Foo'. + Property 'x' is missing in type 'Baz' but required in type 'Foo'. ==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck25.ts (1 errors) ==== @@ -19,17 +15,13 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck25.ts(4,5): error var g3: () => Iterable = function* () { ~~ !!! error TS2322: Type '() => Generator' is not assignable to type '() => Iterable'. -!!! error TS2322: Type 'Generator' is not assignable to type 'Iterable'. -!!! error TS2322: Types of property '[Symbol.iterator]' are incompatible. -!!! error TS2322: Type '() => Generator' is not assignable to type '() => Iterator'. -!!! error TS2322: Type 'Generator' is not assignable to type 'Iterator'. -!!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '(...args: [] | [undefined]) => IteratorResult' is not assignable to type '(...args: [] | [undefined]) => IteratorResult'. -!!! error TS2322: Type 'IteratorResult' is not assignable to type 'IteratorResult'. -!!! error TS2322: Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. -!!! error TS2322: Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. -!!! error TS2322: Type 'Bar | Baz' is not assignable to type 'Foo'. -!!! error TS2322: Property 'x' is missing in type 'Baz' but required in type 'Foo'. +!!! error TS2322: Call signature return types 'Generator' and 'Iterable' are incompatible. +!!! error TS2322: The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types. +!!! error TS2322: Type 'IteratorResult' is not assignable to type 'IteratorResult'. +!!! error TS2322: Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. +!!! error TS2322: Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. +!!! error TS2322: Type 'Bar | Baz' is not assignable to type 'Foo'. +!!! error TS2322: Property 'x' is missing in type 'Baz' but required in type 'Foo'. !!! related TS2728 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck25.ts:1:13: 'x' is declared here. yield; yield new Bar; diff --git a/tests/baselines/reference/generatorTypeCheck63.errors.txt b/tests/baselines/reference/generatorTypeCheck63.errors.txt index 60dfb089822..10cafbe0ced 100644 --- a/tests/baselines/reference/generatorTypeCheck63.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck63.errors.txt @@ -1,11 +1,10 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(24,61): error TS2345: Argument of type '(state: State) => Generator' is not assignable to parameter of type '(a: State) => IterableIterator'. - Type 'Generator' is not assignable to type 'IterableIterator'. - Types of property 'next' are incompatible. - Type '(...args: [] | [undefined]) => IteratorResult' is not assignable to type '(...args: [] | [undefined]) => IteratorResult'. - Type 'IteratorResult' is not assignable to type 'IteratorResult'. - Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. - Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. - Type 'number' is not assignable to type 'State'. + Call signature return types 'Generator' and 'IterableIterator' are incompatible. + The types returned by 'next(...)' are incompatible between these types. + Type 'IteratorResult' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. + Type 'number' is not assignable to type 'State'. ==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts (1 errors) ==== @@ -35,13 +34,12 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(24,61): err export const Nothing: Strategy = strategy("Nothing", function* (state: State) { ~~~~~~~~ !!! error TS2345: Argument of type '(state: State) => Generator' is not assignable to parameter of type '(a: State) => IterableIterator'. -!!! error TS2345: Type 'Generator' is not assignable to type 'IterableIterator'. -!!! error TS2345: Types of property 'next' are incompatible. -!!! error TS2345: Type '(...args: [] | [undefined]) => IteratorResult' is not assignable to type '(...args: [] | [undefined]) => IteratorResult'. -!!! error TS2345: Type 'IteratorResult' is not assignable to type 'IteratorResult'. -!!! error TS2345: Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. -!!! error TS2345: Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. -!!! error TS2345: Type 'number' is not assignable to type 'State'. +!!! error TS2345: Call signature return types 'Generator' and 'IterableIterator' are incompatible. +!!! error TS2345: The types returned by 'next(...)' are incompatible between these types. +!!! error TS2345: Type 'IteratorResult' is not assignable to type 'IteratorResult'. +!!! error TS2345: Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. +!!! error TS2345: Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. +!!! error TS2345: Type 'number' is not assignable to type 'State'. yield 1; return state; }); diff --git a/tests/baselines/reference/generatorTypeCheck8.errors.txt b/tests/baselines/reference/generatorTypeCheck8.errors.txt index 6261d419ddd..ca0b1e30366 100644 --- a/tests/baselines/reference/generatorTypeCheck8.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck8.errors.txt @@ -1,10 +1,9 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck8.ts(2,17): error TS2322: Type 'Generator' is not assignable to type 'BadGenerator'. - Types of property 'next' are incompatible. - Type '(...args: [] | [undefined]) => IteratorResult' is not assignable to type '(...args: [] | [undefined]) => IteratorResult'. - Type 'IteratorResult' is not assignable to type 'IteratorResult'. - Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. - Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. - Type 'string' is not assignable to type 'number'. + The types returned by 'next(...)' are incompatible between these types. + Type 'IteratorResult' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. + Type 'string' is not assignable to type 'number'. ==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck8.ts (1 errors) ==== @@ -12,9 +11,8 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck8.ts(2,17): error function* g3(): BadGenerator { } ~~~~~~~~~~~~ !!! error TS2322: Type 'Generator' is not assignable to type 'BadGenerator'. -!!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '(...args: [] | [undefined]) => IteratorResult' is not assignable to type '(...args: [] | [undefined]) => IteratorResult'. -!!! error TS2322: Type 'IteratorResult' is not assignable to type 'IteratorResult'. -!!! error TS2322: Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. -!!! error TS2322: Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file +!!! error TS2322: The types returned by 'next(...)' are incompatible between these types. +!!! error TS2322: Type 'IteratorResult' is not assignable to type 'IteratorResult'. +!!! error TS2322: Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. +!!! error TS2322: Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/genericDefaultsErrors.types b/tests/baselines/reference/genericDefaultsErrors.types index 51b819f9d01..5eaf9af1cc1 100644 --- a/tests/baselines/reference/genericDefaultsErrors.types +++ b/tests/baselines/reference/genericDefaultsErrors.types @@ -70,10 +70,10 @@ type i09t01 = i09<1>; // error >i09t01 : any type i09t02 = i09<1, 2>; // ok ->i09t02 : i09<1, 2, number> +>i09t02 : i09t02 type i09t03 = i09<1, 2, 3>; // ok ->i09t03 : i09<1, 2, 3> +>i09t03 : i09t03 type i09t04 = i09<1, 2, 3, 4>; // error >i09t04 : any diff --git a/tests/baselines/reference/genericTypeAliases.types b/tests/baselines/reference/genericTypeAliases.types index 308c61da725..a092c7c8024 100644 --- a/tests/baselines/reference/genericTypeAliases.types +++ b/tests/baselines/reference/genericTypeAliases.types @@ -143,7 +143,7 @@ interface AB { } type Pair = AB; ->Pair : AB +>Pair : Pair interface TaggedPair extends Pair { tag: string; diff --git a/tests/baselines/reference/generics4.errors.txt b/tests/baselines/reference/generics4.errors.txt index 06bfa122901..6181685983e 100644 --- a/tests/baselines/reference/generics4.errors.txt +++ b/tests/baselines/reference/generics4.errors.txt @@ -1,8 +1,7 @@ tests/cases/compiler/generics4.ts(7,1): error TS2322: Type 'C' is not assignable to type 'C'. Type 'Y' is not assignable to type 'X'. - Types of property 'f' are incompatible. - Type '() => boolean' is not assignable to type '() => string'. - Type 'boolean' is not assignable to type 'string'. + The types returned by 'f()' are incompatible between these types. + Type 'boolean' is not assignable to type 'string'. ==== tests/cases/compiler/generics4.ts (1 errors) ==== @@ -16,6 +15,5 @@ tests/cases/compiler/generics4.ts(7,1): error TS2322: Type 'C' is not assigna ~ !!! error TS2322: Type 'C' is not assignable to type 'C'. !!! error TS2322: Type 'Y' is not assignable to type 'X'. -!!! error TS2322: Types of property 'f' are incompatible. -!!! error TS2322: Type '() => boolean' is not assignable to type '() => string'. -!!! error TS2322: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file +!!! error TS2322: The types returned by 'f()' are incompatible between these types. +!!! error TS2322: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/incompatibleTypes.errors.txt b/tests/baselines/reference/incompatibleTypes.errors.txt index 0b5e587ad53..66d94bea79c 100644 --- a/tests/baselines/reference/incompatibleTypes.errors.txt +++ b/tests/baselines/reference/incompatibleTypes.errors.txt @@ -12,14 +12,12 @@ tests/cases/compiler/incompatibleTypes.ts(34,12): error TS2416: Property 'p1' in tests/cases/compiler/incompatibleTypes.ts(42,5): error TS2769: No overload matches this call. Overload 1 of 2, '(i: IFoo1): void', gave the following error. Argument of type 'C1' is not assignable to parameter of type 'IFoo1'. - Types of property 'p1' are incompatible. - Type '() => string' is not assignable to type '() => number'. - Type 'string' is not assignable to type 'number'. + The types returned by 'p1()' are incompatible between these types. + Type 'string' is not assignable to type 'number'. Overload 2 of 2, '(i: IFoo2): void', gave the following error. Argument of type 'C1' is not assignable to parameter of type 'IFoo2'. - Types of property 'p1' are incompatible. - Type '() => string' is not assignable to type '(s: string) => number'. - Type 'string' is not assignable to type 'number'. + The types returned by 'p1(...)' are incompatible between these types. + Type 'string' is not assignable to type 'number'. tests/cases/compiler/incompatibleTypes.ts(49,7): error TS2769: No overload matches this call. Overload 1 of 2, '(n: { a: { a: string; }; b: string; }): number', gave the following error. Argument of type '{ e: number; f: number; }' is not assignable to parameter of type '{ a: { a: string; }; b: string; }'. @@ -95,14 +93,12 @@ tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => !!! error TS2769: No overload matches this call. !!! error TS2769: Overload 1 of 2, '(i: IFoo1): void', gave the following error. !!! error TS2769: Argument of type 'C1' is not assignable to parameter of type 'IFoo1'. -!!! error TS2769: Types of property 'p1' are incompatible. -!!! error TS2769: Type '() => string' is not assignable to type '() => number'. -!!! error TS2769: Type 'string' is not assignable to type 'number'. +!!! error TS2769: The types returned by 'p1()' are incompatible between these types. +!!! error TS2769: Type 'string' is not assignable to type 'number'. !!! error TS2769: Overload 2 of 2, '(i: IFoo2): void', gave the following error. !!! error TS2769: Argument of type 'C1' is not assignable to parameter of type 'IFoo2'. -!!! error TS2769: Types of property 'p1' are incompatible. -!!! error TS2769: Type '() => string' is not assignable to type '(s: string) => number'. -!!! error TS2769: Type 'string' is not assignable to type 'number'. +!!! error TS2769: The types returned by 'p1(...)' are incompatible between these types. +!!! error TS2769: Type 'string' is not assignable to type 'number'. function of1(n: { a: { a: string; }; b: string; }): number; diff --git a/tests/baselines/reference/indexedAccessPrivateMemberOfGenericConstraint.types b/tests/baselines/reference/indexedAccessPrivateMemberOfGenericConstraint.types index abdbaa84862..f3a96fba6a8 100644 --- a/tests/baselines/reference/indexedAccessPrivateMemberOfGenericConstraint.types +++ b/tests/baselines/reference/indexedAccessPrivateMemberOfGenericConstraint.types @@ -14,7 +14,7 @@ class B { } type X = [T["a"], (T | B)["a"]]; ->X : [T["a"], (B | T)["a"]] +>X : X type Y = T["a"]; >Y : T["a"] diff --git a/tests/baselines/reference/inferTypes1.types b/tests/baselines/reference/inferTypes1.types index 2696b520ae8..f31c230620b 100644 --- a/tests/baselines/reference/inferTypes1.types +++ b/tests/baselines/reference/inferTypes1.types @@ -269,19 +269,19 @@ type T78 = T extends T76 ? T76 : never; >T78 : T78 type Foo = [T, U]; ->Foo : [T, U] +>Foo : Foo type Bar = T extends Foo ? Foo : never; >Bar : Bar type T90 = Bar<[string, string]>; // [string, string] ->T90 : [string, string] +>T90 : Foo type T91 = Bar<[string, "a"]>; // [string, "a"] ->T91 : [string, "a"] +>T91 : Foo type T92 = Bar<[string, "a"] & { x: string }>; // [string, "a"] ->T92 : [string, "a"] +>T92 : Foo >x : string type T93 = Bar<["a", string]>; // never @@ -371,13 +371,13 @@ const z2: string = ex.obj.nested.attr; // Repros from #21631 type A1> = [T, U]; ->A1 : [T, U] +>A1 : A1 type B1 = S extends A1 ? [T, U] : never; >B1 : B1 type A2 = [T, U]; ->A2 : [T, U] +>A2 : A2 type B2 = S extends A2 ? [T, U] : never; >B2 : B2 diff --git a/tests/baselines/reference/inheritedModuleMembersForClodule.errors.txt b/tests/baselines/reference/inheritedModuleMembersForClodule.errors.txt index 0b7e00d95ce..e2b744d5a25 100644 --- a/tests/baselines/reference/inheritedModuleMembersForClodule.errors.txt +++ b/tests/baselines/reference/inheritedModuleMembersForClodule.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/inheritedModuleMembersForClodule.ts(7,7): error TS2417: Class static side 'typeof D' incorrectly extends base class static side 'typeof C'. - Types of property 'foo' are incompatible. - Type '() => number' is not assignable to type '() => string'. - Type 'number' is not assignable to type 'string'. + The types returned by 'foo()' are incompatible between these types. + Type 'number' is not assignable to type 'string'. ==== tests/cases/compiler/inheritedModuleMembersForClodule.ts (1 errors) ==== @@ -14,9 +13,8 @@ tests/cases/compiler/inheritedModuleMembersForClodule.ts(7,7): error TS2417: Cla class D extends C { ~ !!! error TS2417: Class static side 'typeof D' incorrectly extends base class static side 'typeof C'. -!!! error TS2417: Types of property 'foo' are incompatible. -!!! error TS2417: Type '() => number' is not assignable to type '() => string'. -!!! error TS2417: Type 'number' is not assignable to type 'string'. +!!! error TS2417: The types returned by 'foo()' are incompatible between these types. +!!! error TS2417: Type 'number' is not assignable to type 'string'. } module D { diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersection.types b/tests/baselines/reference/interfaceExtendsObjectIntersection.types index cc166a6e57c..af638969078 100644 --- a/tests/baselines/reference/interfaceExtendsObjectIntersection.types +++ b/tests/baselines/reference/interfaceExtendsObjectIntersection.types @@ -15,10 +15,10 @@ type T4 = new () => { a: number }; >a : number type T5 = number[]; ->T5 : number[] +>T5 : T5 type T6 = [string, number]; ->T6 : [string, number] +>T6 : T6 type T7 = { [P in 'a' | 'b' | 'c']: string }; >T7 : T7 diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.types b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.types index 6b81e8d2f54..2fc15b53994 100644 --- a/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.types +++ b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.types @@ -8,10 +8,10 @@ type T2 = T1 & { b: number }; >b : number type T3 = number[]; ->T3 : number[] +>T3 : T3 type T4 = [string, number]; ->T4 : [string, number] +>T4 : T4 type T5 = { [P in 'a' | 'b' | 'c']: string }; >T5 : T5 diff --git a/tests/baselines/reference/interfaceThatHidesBaseProperty2.errors.txt b/tests/baselines/reference/interfaceThatHidesBaseProperty2.errors.txt index f66e13c0d9d..779a160c5a6 100644 --- a/tests/baselines/reference/interfaceThatHidesBaseProperty2.errors.txt +++ b/tests/baselines/reference/interfaceThatHidesBaseProperty2.errors.txt @@ -1,8 +1,6 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatHidesBaseProperty2.ts(5,11): error TS2430: Interface 'Derived' incorrectly extends interface 'Base'. - Types of property 'x' are incompatible. - Type '{ a: string; }' is not assignable to type '{ a: number; }'. - Types of property 'a' are incompatible. - Type 'string' is not assignable to type 'number'. + The types of 'x.a' are incompatible between these types. + Type 'string' is not assignable to type 'number'. ==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatHidesBaseProperty2.ts (1 errors) ==== @@ -13,10 +11,8 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatHidesBaseP interface Derived extends Base { // error ~~~~~~~ !!! error TS2430: Interface 'Derived' incorrectly extends interface 'Base'. -!!! error TS2430: Types of property 'x' are incompatible. -!!! error TS2430: Type '{ a: string; }' is not assignable to type '{ a: number; }'. -!!! error TS2430: Types of property 'a' are incompatible. -!!! error TS2430: Type 'string' is not assignable to type 'number'. +!!! error TS2430: The types of 'x.a' are incompatible between these types. +!!! error TS2430: Type 'string' is not assignable to type 'number'. x: { a: string; }; diff --git a/tests/baselines/reference/interfaceWithMultipleBaseTypes.errors.txt b/tests/baselines/reference/interfaceWithMultipleBaseTypes.errors.txt index 138f3d92096..c885a7859d4 100644 --- a/tests/baselines/reference/interfaceWithMultipleBaseTypes.errors.txt +++ b/tests/baselines/reference/interfaceWithMultipleBaseTypes.errors.txt @@ -1,20 +1,14 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes.ts(21,11): error TS2430: Interface 'Derived2' incorrectly extends interface 'Base2'. - Types of property 'x' are incompatible. - Type '{ a: string; b: number; }' is not assignable to type '{ b: string; }'. - Types of property 'b' are incompatible. - Type 'number' is not assignable to type 'string'. + The types of 'x.b' are incompatible between these types. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes.ts(52,15): error TS2320: Interface 'Derived3' cannot simultaneously extend types 'Base1' and 'Base2'. Named property 'x' of types 'Base1' and 'Base2' are not identical. tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes.ts(54,15): error TS2430: Interface 'Derived4' incorrectly extends interface 'Base1'. - Types of property 'x' are incompatible. - Type '{ a: T; b: T; }' is not assignable to type '{ a: number; }'. - Types of property 'a' are incompatible. - Type 'T' is not assignable to type 'number'. + The types of 'x.a' are incompatible between these types. + Type 'T' is not assignable to type 'number'. tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes.ts(54,15): error TS2430: Interface 'Derived4' incorrectly extends interface 'Base2'. - Types of property 'x' are incompatible. - Type '{ a: T; b: T; }' is not assignable to type '{ b: number; }'. - Types of property 'b' are incompatible. - Type 'T' is not assignable to type 'number'. + The types of 'x.b' are incompatible between these types. + Type 'T' is not assignable to type 'number'. tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes.ts(60,15): error TS2430: Interface 'Derived5' incorrectly extends interface 'Base1'. Types of property 'x' are incompatible. Type 'T' is not assignable to type '{ a: T; }'. @@ -47,10 +41,8 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBa interface Derived2 extends Base1, Base2 { // error ~~~~~~~~ !!! error TS2430: Interface 'Derived2' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'x' are incompatible. -!!! error TS2430: Type '{ a: string; b: number; }' is not assignable to type '{ b: string; }'. -!!! error TS2430: Types of property 'b' are incompatible. -!!! error TS2430: Type 'number' is not assignable to type 'string'. +!!! error TS2430: The types of 'x.b' are incompatible between these types. +!!! error TS2430: Type 'number' is not assignable to type 'string'. x: { a: string; b: number; } @@ -89,16 +81,12 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBa interface Derived4 extends Base1, Base2 { // error ~~~~~~~~ !!! error TS2430: Interface 'Derived4' incorrectly extends interface 'Base1'. -!!! error TS2430: Types of property 'x' are incompatible. -!!! error TS2430: Type '{ a: T; b: T; }' is not assignable to type '{ a: number; }'. -!!! error TS2430: Types of property 'a' are incompatible. -!!! error TS2430: Type 'T' is not assignable to type 'number'. +!!! error TS2430: The types of 'x.a' are incompatible between these types. +!!! error TS2430: Type 'T' is not assignable to type 'number'. ~~~~~~~~ !!! error TS2430: Interface 'Derived4' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'x' are incompatible. -!!! error TS2430: Type '{ a: T; b: T; }' is not assignable to type '{ b: number; }'. -!!! error TS2430: Types of property 'b' are incompatible. -!!! error TS2430: Type 'T' is not assignable to type 'number'. +!!! error TS2430: The types of 'x.b' are incompatible between these types. +!!! error TS2430: Type 'T' is not assignable to type 'number'. x: { a: T; b: T; } diff --git a/tests/baselines/reference/interfaceWithMultipleBaseTypes2.errors.txt b/tests/baselines/reference/interfaceWithMultipleBaseTypes2.errors.txt index b3459233923..9b7b2eff8ec 100644 --- a/tests/baselines/reference/interfaceWithMultipleBaseTypes2.errors.txt +++ b/tests/baselines/reference/interfaceWithMultipleBaseTypes2.errors.txt @@ -1,8 +1,6 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes2.ts(17,11): error TS2430: Interface 'Derived2' incorrectly extends interface 'Base'. - Types of property 'x' are incompatible. - Type '{ a: number; b: string; }' is not assignable to type '{ a?: string; b: string; }'. - Types of property 'a' are incompatible. - Type 'number' is not assignable to type 'string'. + The types of 'x.a' are incompatible between these types. + Type 'number' is not assignable to type 'string'. ==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes2.ts (1 errors) ==== @@ -25,10 +23,8 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBa interface Derived2 extends Base, Base2 { // error ~~~~~~~~ !!! error TS2430: Interface 'Derived2' incorrectly extends interface 'Base'. -!!! error TS2430: Types of property 'x' are incompatible. -!!! error TS2430: Type '{ a: number; b: string; }' is not assignable to type '{ a?: string; b: string; }'. -!!! error TS2430: Types of property 'a' are incompatible. -!!! error TS2430: Type 'number' is not assignable to type 'string'. +!!! error TS2430: The types of 'x.a' are incompatible between these types. +!!! error TS2430: Type 'number' is not assignable to type 'string'. x: { a: number; b: string } } diff --git a/tests/baselines/reference/intersectionTypeWithLeadingOperator.types b/tests/baselines/reference/intersectionTypeWithLeadingOperator.types index 9961f051f7f..826da4d8c51 100644 --- a/tests/baselines/reference/intersectionTypeWithLeadingOperator.types +++ b/tests/baselines/reference/intersectionTypeWithLeadingOperator.types @@ -12,7 +12,7 @@ type B = >bar : number type C = [& { foo: 1 } & { bar: 2 }, & { foo: 3 } & { bar: 4 }]; ->C : [{ foo: 1; } & { bar: 2; }, { foo: 3; } & { bar: 4; }] +>C : C >foo : 1 >bar : 2 >foo : 3 diff --git a/tests/baselines/reference/intersectionWithUnionConstraint.errors.txt b/tests/baselines/reference/intersectionWithUnionConstraint.errors.txt index 97ed1cf4895..7bc436915a1 100644 --- a/tests/baselines/reference/intersectionWithUnionConstraint.errors.txt +++ b/tests/baselines/reference/intersectionWithUnionConstraint.errors.txt @@ -1,23 +1,13 @@ tests/cases/conformance/types/intersection/intersectionWithUnionConstraint.ts(7,9): error TS2322: Type 'T & U' is not assignable to type 'string | number'. - Type 'string | undefined' is not assignable to type 'string | number'. - Type 'undefined' is not assignable to type 'string | number'. - Type 'T & U' is not assignable to type 'number'. + Type 'T & U' is not assignable to type 'number'. tests/cases/conformance/types/intersection/intersectionWithUnionConstraint.ts(8,9): error TS2322: Type 'T & U' is not assignable to type 'string | null'. - Type 'string | undefined' is not assignable to type 'string | null'. - Type 'undefined' is not assignable to type 'string | null'. - Type 'T & U' is not assignable to type 'string'. + Type 'T & U' is not assignable to type 'string'. tests/cases/conformance/types/intersection/intersectionWithUnionConstraint.ts(10,9): error TS2322: Type 'T & U' is not assignable to type 'number | null'. - Type 'string | undefined' is not assignable to type 'number | null'. - Type 'undefined' is not assignable to type 'number | null'. - Type 'T & U' is not assignable to type 'number'. + Type 'T & U' is not assignable to type 'number'. tests/cases/conformance/types/intersection/intersectionWithUnionConstraint.ts(11,9): error TS2322: Type 'T & U' is not assignable to type 'number | undefined'. - Type 'string | undefined' is not assignable to type 'number | undefined'. - Type 'string' is not assignable to type 'number | undefined'. - Type 'T & U' is not assignable to type 'number'. + Type 'T & U' is not assignable to type 'number'. tests/cases/conformance/types/intersection/intersectionWithUnionConstraint.ts(12,9): error TS2322: Type 'T & U' is not assignable to type 'null | undefined'. - Type 'string | undefined' is not assignable to type 'null | undefined'. - Type 'string' is not assignable to type 'null | undefined'. - Type 'T & U' is not assignable to type 'null'. + Type 'T & U' is not assignable to type 'null'. ==== tests/cases/conformance/types/intersection/intersectionWithUnionConstraint.ts (5 errors) ==== @@ -30,34 +20,24 @@ tests/cases/conformance/types/intersection/intersectionWithUnionConstraint.ts(12 let y1: string | number = x; // Error ~~ !!! error TS2322: Type 'T & U' is not assignable to type 'string | number'. -!!! error TS2322: Type 'string | undefined' is not assignable to type 'string | number'. -!!! error TS2322: Type 'undefined' is not assignable to type 'string | number'. -!!! error TS2322: Type 'T & U' is not assignable to type 'number'. +!!! error TS2322: Type 'T & U' is not assignable to type 'number'. let y2: string | null = x; // Error ~~ !!! error TS2322: Type 'T & U' is not assignable to type 'string | null'. -!!! error TS2322: Type 'string | undefined' is not assignable to type 'string | null'. -!!! error TS2322: Type 'undefined' is not assignable to type 'string | null'. -!!! error TS2322: Type 'T & U' is not assignable to type 'string'. +!!! error TS2322: Type 'T & U' is not assignable to type 'string'. let y3: string | undefined = x; let y4: number | null = x; // Error ~~ !!! error TS2322: Type 'T & U' is not assignable to type 'number | null'. -!!! error TS2322: Type 'string | undefined' is not assignable to type 'number | null'. -!!! error TS2322: Type 'undefined' is not assignable to type 'number | null'. -!!! error TS2322: Type 'T & U' is not assignable to type 'number'. +!!! error TS2322: Type 'T & U' is not assignable to type 'number'. let y5: number | undefined = x; // Error ~~ !!! error TS2322: Type 'T & U' is not assignable to type 'number | undefined'. -!!! error TS2322: Type 'string | undefined' is not assignable to type 'number | undefined'. -!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'. -!!! error TS2322: Type 'T & U' is not assignable to type 'number'. +!!! error TS2322: Type 'T & U' is not assignable to type 'number'. let y6: null | undefined = x; // Error ~~ !!! error TS2322: Type 'T & U' is not assignable to type 'null | undefined'. -!!! error TS2322: Type 'string | undefined' is not assignable to type 'null | undefined'. -!!! error TS2322: Type 'string' is not assignable to type 'null | undefined'. -!!! error TS2322: Type 'T & U' is not assignable to type 'null'. +!!! error TS2322: Type 'T & U' is not assignable to type 'null'. } type T1 = (string | number | undefined) & (string | null | undefined); // string | undefined diff --git a/tests/baselines/reference/invariantGenericErrorElaboration.errors.txt b/tests/baselines/reference/invariantGenericErrorElaboration.errors.txt index 0bd79bcf11d..7ab83c61bcd 100644 --- a/tests/baselines/reference/invariantGenericErrorElaboration.errors.txt +++ b/tests/baselines/reference/invariantGenericErrorElaboration.errors.txt @@ -1,13 +1,7 @@ tests/cases/compiler/invariantGenericErrorElaboration.ts(3,7): error TS2322: Type 'Num' is not assignable to type 'Runtype'. - Types of property 'constraint' are incompatible. - Type 'Constraint' is not assignable to type 'Constraint>'. - Types of property 'constraint' are incompatible. - Type 'Constraint>' is not assignable to type 'Constraint>>'. - Types of property 'constraint' are incompatible. - Type 'Constraint>>' is not assignable to type 'Constraint>>>'. - Type 'Constraint>>' is not assignable to type 'Constraint>'. - Types of property 'underlying' are incompatible. - Type 'Constraint>' is not assignable to type 'Constraint'. + The types of 'constraint.constraint.constraint' are incompatible between these types. + Type 'Constraint>>' is not assignable to type 'Constraint>>>'. + Type 'Constraint>' is not assignable to type 'Constraint'. tests/cases/compiler/invariantGenericErrorElaboration.ts(4,19): error TS2322: Type 'Num' is not assignable to type 'Runtype'. @@ -17,16 +11,9 @@ tests/cases/compiler/invariantGenericErrorElaboration.ts(4,19): error TS2322: Ty const wat: Runtype = Num; ~~~ !!! error TS2322: Type 'Num' is not assignable to type 'Runtype'. -!!! error TS2322: Types of property 'constraint' are incompatible. -!!! error TS2322: Type 'Constraint' is not assignable to type 'Constraint>'. -!!! error TS2322: Types of property 'constraint' are incompatible. -!!! error TS2322: Type 'Constraint>' is not assignable to type 'Constraint>>'. -!!! error TS2322: Types of property 'constraint' are incompatible. -!!! error TS2322: Type 'Constraint>>' is not assignable to type 'Constraint>>>'. -!!! error TS2322: Type 'Constraint>>' is not assignable to type 'Constraint>'. -!!! error TS2322: Types of property 'underlying' are incompatible. -!!! error TS2322: Type 'Constraint>' is not assignable to type 'Constraint'. -!!! related TS2728 tests/cases/compiler/invariantGenericErrorElaboration.ts:12:3: 'tag' is declared here. +!!! error TS2322: The types of 'constraint.constraint.constraint' are incompatible between these types. +!!! error TS2322: Type 'Constraint>>' is not assignable to type 'Constraint>>>'. +!!! error TS2322: Type 'Constraint>' is not assignable to type 'Constraint'. const Foo = Obj({ foo: Num }) ~~~ !!! error TS2322: Type 'Num' is not assignable to type 'Runtype'. diff --git a/tests/baselines/reference/iterableArrayPattern28.errors.txt b/tests/baselines/reference/iterableArrayPattern28.errors.txt index 7a1ff6cf42c..605c6feb405 100644 --- a/tests/baselines/reference/iterableArrayPattern28.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern28.errors.txt @@ -1,18 +1,14 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts(2,24): error TS2769: No overload matches this call. Overload 1 of 3, '(iterable: Iterable): Map', gave the following error. Argument of type '([string, number] | [string, boolean])[]' is not assignable to parameter of type 'Iterable'. - Types of property '[Symbol.iterator]' are incompatible. - Type '() => IterableIterator<[string, number] | [string, boolean]>' is not assignable to type '() => Iterator'. - Type 'IterableIterator<[string, number] | [string, boolean]>' is not assignable to type 'Iterator'. - Types of property 'next' are incompatible. - Type '(...args: [] | [undefined]) => IteratorResult<[string, number] | [string, boolean], any>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult'. - Type 'IteratorResult<[string, number] | [string, boolean], any>' is not assignable to type 'IteratorResult'. - Type 'IteratorYieldResult<[string, number] | [string, boolean]>' is not assignable to type 'IteratorResult'. - Type 'IteratorYieldResult<[string, number] | [string, boolean]>' is not assignable to type 'IteratorYieldResult'. - Type '[string, number] | [string, boolean]' is not assignable to type 'readonly [string, number]'. - Type '[string, boolean]' is not assignable to type 'readonly [string, number]'. - Types of property '1' are incompatible. - Type 'boolean' is not assignable to type 'number'. + The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types. + Type 'IteratorResult<[string, number] | [string, boolean], any>' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult<[string, number] | [string, boolean]>' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult<[string, number] | [string, boolean]>' is not assignable to type 'IteratorYieldResult'. + Type '[string, number] | [string, boolean]' is not assignable to type 'readonly [string, number]'. + Type '[string, boolean]' is not assignable to type 'readonly [string, number]'. + Types of property '1' are incompatible. + Type 'boolean' is not assignable to type 'number'. Overload 2 of 3, '(entries?: readonly (readonly [string, number])[]): Map', gave the following error. Type 'true' is not assignable to type 'number'. @@ -24,17 +20,13 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts(2,24): error !!! error TS2769: No overload matches this call. !!! error TS2769: Overload 1 of 3, '(iterable: Iterable): Map', gave the following error. !!! error TS2769: Argument of type '([string, number] | [string, boolean])[]' is not assignable to parameter of type 'Iterable'. -!!! error TS2769: Types of property '[Symbol.iterator]' are incompatible. -!!! error TS2769: Type '() => IterableIterator<[string, number] | [string, boolean]>' is not assignable to type '() => Iterator'. -!!! error TS2769: Type 'IterableIterator<[string, number] | [string, boolean]>' is not assignable to type 'Iterator'. -!!! error TS2769: Types of property 'next' are incompatible. -!!! error TS2769: Type '(...args: [] | [undefined]) => IteratorResult<[string, number] | [string, boolean], any>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult'. -!!! error TS2769: Type 'IteratorResult<[string, number] | [string, boolean], any>' is not assignable to type 'IteratorResult'. -!!! error TS2769: Type 'IteratorYieldResult<[string, number] | [string, boolean]>' is not assignable to type 'IteratorResult'. -!!! error TS2769: Type 'IteratorYieldResult<[string, number] | [string, boolean]>' is not assignable to type 'IteratorYieldResult'. -!!! error TS2769: Type '[string, number] | [string, boolean]' is not assignable to type 'readonly [string, number]'. -!!! error TS2769: Type '[string, boolean]' is not assignable to type 'readonly [string, number]'. -!!! error TS2769: Types of property '1' are incompatible. -!!! error TS2769: Type 'boolean' is not assignable to type 'number'. +!!! error TS2769: The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types. +!!! error TS2769: Type 'IteratorResult<[string, number] | [string, boolean], any>' is not assignable to type 'IteratorResult'. +!!! error TS2769: Type 'IteratorYieldResult<[string, number] | [string, boolean]>' is not assignable to type 'IteratorResult'. +!!! error TS2769: Type 'IteratorYieldResult<[string, number] | [string, boolean]>' is not assignable to type 'IteratorYieldResult'. +!!! error TS2769: Type '[string, number] | [string, boolean]' is not assignable to type 'readonly [string, number]'. +!!! error TS2769: Type '[string, boolean]' is not assignable to type 'readonly [string, number]'. +!!! error TS2769: Types of property '1' are incompatible. +!!! error TS2769: Type 'boolean' is not assignable to type 'number'. !!! error TS2769: Overload 2 of 3, '(entries?: readonly (readonly [string, number])[]): Map', gave the following error. !!! error TS2769: Type 'true' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInArray6.errors.txt b/tests/baselines/reference/iteratorSpreadInArray6.errors.txt index 0b114bc6477..202c0ab3bf2 100644 --- a/tests/baselines/reference/iteratorSpreadInArray6.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInArray6.errors.txt @@ -1,10 +1,9 @@ tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts(15,14): error TS2769: No overload matches this call. Overload 1 of 2, '(...items: ConcatArray[]): number[]', gave the following error. Argument of type 'symbol[]' is not assignable to parameter of type 'ConcatArray'. - Types of property 'slice' are incompatible. - Type '(start?: number, end?: number) => symbol[]' is not assignable to type '(start?: number, end?: number) => number[]'. - Type 'symbol[]' is not assignable to type 'number[]'. - Type 'symbol' is not assignable to type 'number'. + The types returned by 'slice(...)' are incompatible between these types. + Type 'symbol[]' is not assignable to type 'number[]'. + Type 'symbol' is not assignable to type 'number'. Overload 2 of 2, '(...items: (number | ConcatArray)[]): number[]', gave the following error. Argument of type 'symbol[]' is not assignable to parameter of type 'number | ConcatArray'. Type 'symbol[]' is not assignable to type 'ConcatArray'. @@ -30,10 +29,9 @@ tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts(15,14): error TS276 !!! error TS2769: No overload matches this call. !!! error TS2769: Overload 1 of 2, '(...items: ConcatArray[]): number[]', gave the following error. !!! error TS2769: Argument of type 'symbol[]' is not assignable to parameter of type 'ConcatArray'. -!!! error TS2769: Types of property 'slice' are incompatible. -!!! error TS2769: Type '(start?: number, end?: number) => symbol[]' is not assignable to type '(start?: number, end?: number) => number[]'. -!!! error TS2769: Type 'symbol[]' is not assignable to type 'number[]'. -!!! error TS2769: Type 'symbol' is not assignable to type 'number'. +!!! error TS2769: The types returned by 'slice(...)' are incompatible between these types. +!!! error TS2769: Type 'symbol[]' is not assignable to type 'number[]'. +!!! error TS2769: Type 'symbol' is not assignable to type 'number'. !!! error TS2769: Overload 2 of 2, '(...items: (number | ConcatArray)[]): number[]', gave the following error. !!! error TS2769: Argument of type 'symbol[]' is not assignable to parameter of type 'number | ConcatArray'. !!! error TS2769: Type 'symbol[]' is not assignable to type 'ConcatArray'. \ No newline at end of file diff --git a/tests/baselines/reference/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.types b/tests/baselines/reference/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.types index dd302f40679..59292bac60f 100644 --- a/tests/baselines/reference/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.types +++ b/tests/baselines/reference/jsxChildrenSingleChildConfusableWithMultipleChildrenNoError.types @@ -5,12 +5,12 @@ import * as React from 'react' >React : typeof React type Tab = [string, React.ReactNode] // [tabName, tabContent] ->Tab : [string, React.ReactNode] +>Tab : Tab >React : any interface Props { children: Tab[] ->children : [string, React.ReactNode][] +>children : Tab[] } function TabLayout(props: Props) { diff --git a/tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt b/tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt index 69f992447e8..bb628d4f4fb 100644 --- a/tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt +++ b/tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt @@ -48,8 +48,6 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(103,9): error 'string & keyof T' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'. Type 'string' is not assignable to type 'K'. 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'. - Type 'string' is not assignable to type 'K'. - 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'. tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(105,9): error TS2322: Type 'T[Extract]' is not assignable to type 'T[K]'. Type 'Extract' is not assignable to type 'K'. 'Extract' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'. @@ -68,8 +66,6 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(114,5): error 'string & keyof T' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. Type 'string' is not assignable to type 'J'. 'string' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. - Type 'string' is not assignable to type 'J'. - 'string' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(117,5): error TS2322: Type 'T[K]' is not assignable to type 'U[J]'. Type 'T' is not assignable to type 'U'. 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'. @@ -264,8 +260,6 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(142,5): error !!! error TS2322: 'string & keyof T' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'. !!! error TS2322: Type 'string' is not assignable to type 'K'. !!! error TS2322: 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'. -!!! error TS2322: Type 'string' is not assignable to type 'K'. -!!! error TS2322: 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string'. t[key] = tk; // ok, T[K] ==> T[keyof T] tk = t[key]; // error, T[keyof T] =/=> T[K] ~~ @@ -299,8 +293,6 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(142,5): error !!! error TS2322: 'string & keyof T' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. !!! error TS2322: Type 'string' is not assignable to type 'J'. !!! error TS2322: 'string' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. -!!! error TS2322: Type 'string' is not assignable to type 'J'. -!!! error TS2322: 'string' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. tk = uj; uj = tk; // error diff --git a/tests/baselines/reference/mapOnTupleTypes02.types b/tests/baselines/reference/mapOnTupleTypes02.types index 2bb394ec120..3f443a735cb 100644 --- a/tests/baselines/reference/mapOnTupleTypes02.types +++ b/tests/baselines/reference/mapOnTupleTypes02.types @@ -1,15 +1,15 @@ === tests/cases/compiler/mapOnTupleTypes02.ts === export type Point = [number, number]; ->Point : [number, number] +>Point : Point export function increment(point: Point) { ->increment : (point: [number, number]) => number[] ->point : [number, number] +>increment : (point: Point) => number[] +>point : Point return point.map(d => d + 1); >point.map(d => d + 1) : number[] >point.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] ->point : [number, number] +>point : Point >map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] >d => d + 1 : (d: number) => number >d : number diff --git a/tests/baselines/reference/mappedTypesArraysTuples.types b/tests/baselines/reference/mappedTypesArraysTuples.types index 6b43cd510fb..2ec00ad565e 100644 --- a/tests/baselines/reference/mappedTypesArraysTuples.types +++ b/tests/baselines/reference/mappedTypesArraysTuples.types @@ -66,7 +66,7 @@ type B = { b: string }; >b : string type T40 = Boxified
| [A, B] | string | string[]>; ->T40 : string | Box[] | Boxified | Box[] | readonly Box[] | [Box, Box] +>T40 : string | Box[] | Boxified | readonly Box[] | Box[] | [Box, Box] type ReadWrite = { -readonly [P in keyof T] : T[P] }; >ReadWrite : ReadWrite diff --git a/tests/baselines/reference/mergedDeclarations7.errors.txt b/tests/baselines/reference/mergedDeclarations7.errors.txt index cd9b3a5e939..bc09ea081a3 100644 --- a/tests/baselines/reference/mergedDeclarations7.errors.txt +++ b/tests/baselines/reference/mergedDeclarations7.errors.txt @@ -1,7 +1,6 @@ tests/cases/compiler/test.ts(4,5): error TS2322: Type 'PassportStatic' is not assignable to type 'Passport'. - Types of property 'use' are incompatible. - Type '() => PassportStatic' is not assignable to type '() => this'. - Type 'PassportStatic' is not assignable to type 'this'. + The types returned by 'use()' are incompatible between these types. + Type 'PassportStatic' is not assignable to type 'this'. ==== tests/cases/compiler/passport.d.ts (0 errors) ==== @@ -27,6 +26,5 @@ tests/cases/compiler/test.ts(4,5): error TS2322: Type 'PassportStatic' is not as let p: Passport = passport.use(); ~ !!! error TS2322: Type 'PassportStatic' is not assignable to type 'Passport'. -!!! error TS2322: Types of property 'use' are incompatible. -!!! error TS2322: Type '() => PassportStatic' is not assignable to type '() => this'. -!!! error TS2322: Type 'PassportStatic' is not assignable to type 'this'. \ No newline at end of file +!!! error TS2322: The types returned by 'use()' are incompatible between these types. +!!! error TS2322: Type 'PassportStatic' is not assignable to type 'this'. \ No newline at end of file diff --git a/tests/baselines/reference/mixinIntersectionIsValidbaseType.js b/tests/baselines/reference/mixinIntersectionIsValidbaseType.js new file mode 100644 index 00000000000..ed02aecd53f --- /dev/null +++ b/tests/baselines/reference/mixinIntersectionIsValidbaseType.js @@ -0,0 +1,77 @@ +//// [mixinIntersectionIsValidbaseType.ts] +export type Constructor = new (...args: any[]) => T; + +export interface Initable { + init(...args: any[]): void; +} + +/** + * Plain mixin where the superclass must be Initable + */ +export const Serializable = & Initable>( + SuperClass: K +) => { + const LocalMixin = (InnerSuperClass: K) => { + return class SerializableLocal extends InnerSuperClass { + } + }; + let ResultClass = LocalMixin(SuperClass); + return ResultClass; +}; + +const AMixin = & Initable>(SuperClass: K) => { + let SomeHowOkay = class A extends SuperClass { + }; + + let SomeHowNotOkay = class A extends Serializable(SuperClass) { + }; +}; + +//// [mixinIntersectionIsValidbaseType.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 __()); + }; +})(); +exports.__esModule = true; +/** + * Plain mixin where the superclass must be Initable + */ +exports.Serializable = function (SuperClass) { + var LocalMixin = function (InnerSuperClass) { + return /** @class */ (function (_super) { + __extends(SerializableLocal, _super); + function SerializableLocal() { + return _super !== null && _super.apply(this, arguments) || this; + } + return SerializableLocal; + }(InnerSuperClass)); + }; + var ResultClass = LocalMixin(SuperClass); + return ResultClass; +}; +var AMixin = function (SuperClass) { + var SomeHowOkay = /** @class */ (function (_super) { + __extends(A, _super); + function A() { + return _super !== null && _super.apply(this, arguments) || this; + } + return A; + }(SuperClass)); + var SomeHowNotOkay = /** @class */ (function (_super) { + __extends(A, _super); + function A() { + return _super !== null && _super.apply(this, arguments) || this; + } + return A; + }(exports.Serializable(SuperClass))); +}; diff --git a/tests/baselines/reference/mixinIntersectionIsValidbaseType.symbols b/tests/baselines/reference/mixinIntersectionIsValidbaseType.symbols new file mode 100644 index 00000000000..69fe63bab23 --- /dev/null +++ b/tests/baselines/reference/mixinIntersectionIsValidbaseType.symbols @@ -0,0 +1,74 @@ +=== tests/cases/compiler/mixinIntersectionIsValidbaseType.ts === +export type Constructor = new (...args: any[]) => T; +>Constructor : Symbol(Constructor, Decl(mixinIntersectionIsValidbaseType.ts, 0, 0)) +>T : Symbol(T, Decl(mixinIntersectionIsValidbaseType.ts, 0, 24)) +>args : Symbol(args, Decl(mixinIntersectionIsValidbaseType.ts, 0, 58)) +>T : Symbol(T, Decl(mixinIntersectionIsValidbaseType.ts, 0, 24)) + +export interface Initable { +>Initable : Symbol(Initable, Decl(mixinIntersectionIsValidbaseType.ts, 0, 79)) + + init(...args: any[]): void; +>init : Symbol(Initable.init, Decl(mixinIntersectionIsValidbaseType.ts, 2, 27)) +>args : Symbol(args, Decl(mixinIntersectionIsValidbaseType.ts, 3, 9)) +} + +/** + * Plain mixin where the superclass must be Initable + */ +export const Serializable = & Initable>( +>Serializable : Symbol(Serializable, Decl(mixinIntersectionIsValidbaseType.ts, 9, 12)) +>K : Symbol(K, Decl(mixinIntersectionIsValidbaseType.ts, 9, 29)) +>Constructor : Symbol(Constructor, Decl(mixinIntersectionIsValidbaseType.ts, 0, 0)) +>Initable : Symbol(Initable, Decl(mixinIntersectionIsValidbaseType.ts, 0, 79)) +>Initable : Symbol(Initable, Decl(mixinIntersectionIsValidbaseType.ts, 0, 79)) + + SuperClass: K +>SuperClass : Symbol(SuperClass, Decl(mixinIntersectionIsValidbaseType.ts, 9, 73)) +>K : Symbol(K, Decl(mixinIntersectionIsValidbaseType.ts, 9, 29)) + +) => { + const LocalMixin = (InnerSuperClass: K) => { +>LocalMixin : Symbol(LocalMixin, Decl(mixinIntersectionIsValidbaseType.ts, 12, 9)) +>InnerSuperClass : Symbol(InnerSuperClass, Decl(mixinIntersectionIsValidbaseType.ts, 12, 24)) +>K : Symbol(K, Decl(mixinIntersectionIsValidbaseType.ts, 9, 29)) + + return class SerializableLocal extends InnerSuperClass { +>SerializableLocal : Symbol(SerializableLocal, Decl(mixinIntersectionIsValidbaseType.ts, 13, 14)) +>InnerSuperClass : Symbol(InnerSuperClass, Decl(mixinIntersectionIsValidbaseType.ts, 12, 24)) + } + }; + let ResultClass = LocalMixin(SuperClass); +>ResultClass : Symbol(ResultClass, Decl(mixinIntersectionIsValidbaseType.ts, 16, 7)) +>LocalMixin : Symbol(LocalMixin, Decl(mixinIntersectionIsValidbaseType.ts, 12, 9)) +>SuperClass : Symbol(SuperClass, Decl(mixinIntersectionIsValidbaseType.ts, 9, 73)) + + return ResultClass; +>ResultClass : Symbol(ResultClass, Decl(mixinIntersectionIsValidbaseType.ts, 16, 7)) + +}; + +const AMixin = & Initable>(SuperClass: K) => { +>AMixin : Symbol(AMixin, Decl(mixinIntersectionIsValidbaseType.ts, 20, 5)) +>K : Symbol(K, Decl(mixinIntersectionIsValidbaseType.ts, 20, 16)) +>Constructor : Symbol(Constructor, Decl(mixinIntersectionIsValidbaseType.ts, 0, 0)) +>Initable : Symbol(Initable, Decl(mixinIntersectionIsValidbaseType.ts, 0, 79)) +>Initable : Symbol(Initable, Decl(mixinIntersectionIsValidbaseType.ts, 0, 79)) +>SuperClass : Symbol(SuperClass, Decl(mixinIntersectionIsValidbaseType.ts, 20, 60)) +>K : Symbol(K, Decl(mixinIntersectionIsValidbaseType.ts, 20, 16)) + + let SomeHowOkay = class A extends SuperClass { +>SomeHowOkay : Symbol(SomeHowOkay, Decl(mixinIntersectionIsValidbaseType.ts, 21, 7)) +>A : Symbol(A, Decl(mixinIntersectionIsValidbaseType.ts, 21, 21)) +>SuperClass : Symbol(SuperClass, Decl(mixinIntersectionIsValidbaseType.ts, 20, 60)) + + }; + + let SomeHowNotOkay = class A extends Serializable(SuperClass) { +>SomeHowNotOkay : Symbol(SomeHowNotOkay, Decl(mixinIntersectionIsValidbaseType.ts, 24, 7)) +>A : Symbol(A, Decl(mixinIntersectionIsValidbaseType.ts, 24, 24)) +>Serializable : Symbol(Serializable, Decl(mixinIntersectionIsValidbaseType.ts, 9, 12)) +>SuperClass : Symbol(SuperClass, Decl(mixinIntersectionIsValidbaseType.ts, 20, 60)) + + }; +}; diff --git a/tests/baselines/reference/mixinIntersectionIsValidbaseType.types b/tests/baselines/reference/mixinIntersectionIsValidbaseType.types new file mode 100644 index 00000000000..c828188dcd6 --- /dev/null +++ b/tests/baselines/reference/mixinIntersectionIsValidbaseType.types @@ -0,0 +1,67 @@ +=== tests/cases/compiler/mixinIntersectionIsValidbaseType.ts === +export type Constructor = new (...args: any[]) => T; +>Constructor : Constructor +>args : any[] + +export interface Initable { + init(...args: any[]): void; +>init : (...args: any[]) => void +>args : any[] +} + +/** + * Plain mixin where the superclass must be Initable + */ +export const Serializable = & Initable>( +>Serializable : & Initable>(SuperClass: K) => { new (...args: any[]): SerializableLocal; prototype: Serializable.SerializableLocal; init(...args: any[]): void; } & K +> & Initable>( SuperClass: K) => { const LocalMixin = (InnerSuperClass: K) => { return class SerializableLocal extends InnerSuperClass { } }; let ResultClass = LocalMixin(SuperClass); return ResultClass;} : & Initable>(SuperClass: K) => { new (...args: any[]): SerializableLocal; prototype: Serializable.SerializableLocal; init(...args: any[]): void; } & K + + SuperClass: K +>SuperClass : K + +) => { + const LocalMixin = (InnerSuperClass: K) => { +>LocalMixin : (InnerSuperClass: K) => { new (...args: any[]): SerializableLocal; prototype: Serializable.SerializableLocal; init(...args: any[]): void; } & K +>(InnerSuperClass: K) => { return class SerializableLocal extends InnerSuperClass { } } : (InnerSuperClass: K) => { new (...args: any[]): SerializableLocal; prototype: Serializable.SerializableLocal; init(...args: any[]): void; } & K +>InnerSuperClass : K + + return class SerializableLocal extends InnerSuperClass { +>class SerializableLocal extends InnerSuperClass { } : { new (...args: any[]): SerializableLocal; prototype: Serializable.SerializableLocal; init(...args: any[]): void; } & K +>SerializableLocal : { new (...args: any[]): SerializableLocal; prototype: Serializable.SerializableLocal; init(...args: any[]): void; } & K +>InnerSuperClass : Initable + } + }; + let ResultClass = LocalMixin(SuperClass); +>ResultClass : { new (...args: any[]): SerializableLocal; prototype: Serializable.SerializableLocal; init(...args: any[]): void; } & K +>LocalMixin(SuperClass) : { new (...args: any[]): SerializableLocal; prototype: Serializable.SerializableLocal; init(...args: any[]): void; } & K +>LocalMixin : (InnerSuperClass: K) => { new (...args: any[]): SerializableLocal; prototype: Serializable.SerializableLocal; init(...args: any[]): void; } & K +>SuperClass : K + + return ResultClass; +>ResultClass : { new (...args: any[]): SerializableLocal; prototype: Serializable.SerializableLocal; init(...args: any[]): void; } & K + +}; + +const AMixin = & Initable>(SuperClass: K) => { +>AMixin : & Initable>(SuperClass: K) => void +> & Initable>(SuperClass: K) => { let SomeHowOkay = class A extends SuperClass { }; let SomeHowNotOkay = class A extends Serializable(SuperClass) { };} : & Initable>(SuperClass: K) => void +>SuperClass : K + + let SomeHowOkay = class A extends SuperClass { +>SomeHowOkay : { new (...args: any[]): A; prototype: AMixin.A; init(...args: any[]): void; } & K +>class A extends SuperClass { } : { new (...args: any[]): A; prototype: AMixin.A; init(...args: any[]): void; } & K +>A : { new (...args: any[]): A; prototype: AMixin.A; init(...args: any[]): void; } & K +>SuperClass : Initable + + }; + + let SomeHowNotOkay = class A extends Serializable(SuperClass) { +>SomeHowNotOkay : { new (...args: any[]): A; prototype: AMixin.A; init: (...args: any[]) => void; } & K +>class A extends Serializable(SuperClass) { } : { new (...args: any[]): A; prototype: AMixin.A; init: (...args: any[]) => void; } & K +>A : { new (...args: any[]): A; prototype: AMixin.A; init: (...args: any[]) => void; } & K +>Serializable(SuperClass) : Serializable.SerializableLocal & Initable +>Serializable : & Initable>(SuperClass: K) => { new (...args: any[]): SerializableLocal; prototype: Serializable.SerializableLocal; init(...args: any[]): void; } & K +>SuperClass : K + + }; +}; diff --git a/tests/baselines/reference/multiLineErrors.errors.txt b/tests/baselines/reference/multiLineErrors.errors.txt index 70366aeabed..851425baef4 100644 --- a/tests/baselines/reference/multiLineErrors.errors.txt +++ b/tests/baselines/reference/multiLineErrors.errors.txt @@ -1,9 +1,7 @@ tests/cases/compiler/multiLineErrors.ts(3,22): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/compiler/multiLineErrors.ts(21,1): error TS2322: Type 'A2' is not assignable to type 'A1'. - Types of property 'x' are incompatible. - Type '{ y: string; }' is not assignable to type '{ y: number; }'. - Types of property 'y' are incompatible. - Type 'string' is not assignable to type 'number'. + The types of 'x.y' are incompatible between these types. + Type 'string' is not assignable to type 'number'. ==== tests/cases/compiler/multiLineErrors.ts (2 errors) ==== @@ -35,8 +33,6 @@ tests/cases/compiler/multiLineErrors.ts(21,1): error TS2322: Type 'A2' is not as t1 = t2; ~~ !!! error TS2322: Type 'A2' is not assignable to type 'A1'. -!!! error TS2322: Types of property 'x' are incompatible. -!!! error TS2322: Type '{ y: string; }' is not assignable to type '{ y: number; }'. -!!! error TS2322: Types of property 'y' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: The types of 'x.y' are incompatible between these types. +!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/mutuallyRecursiveCallbacks.errors.txt b/tests/baselines/reference/mutuallyRecursiveCallbacks.errors.txt index bb90bcee999..63a568bf10a 100644 --- a/tests/baselines/reference/mutuallyRecursiveCallbacks.errors.txt +++ b/tests/baselines/reference/mutuallyRecursiveCallbacks.errors.txt @@ -1,9 +1,8 @@ tests/cases/compiler/mutuallyRecursiveCallbacks.ts(7,1): error TS2322: Type '(bar: Bar) => void' is not assignable to type 'Bar<{}>'. Types of parameters 'bar' and 'foo' are incompatible. Types of parameters 'bar' and 'foo' are incompatible. - Type 'Foo' is not assignable to type 'Bar<{}>'. - Types of parameters 'bar' and 'foo' are incompatible. - Type 'void' is not assignable to type 'Foo'. + Types of parameters 'bar' and 'foo' are incompatible. + Type 'void' is not assignable to type 'Foo'. ==== tests/cases/compiler/mutuallyRecursiveCallbacks.ts (1 errors) ==== @@ -18,7 +17,6 @@ tests/cases/compiler/mutuallyRecursiveCallbacks.ts(7,1): error TS2322: Type ' !!! error TS2322: Type '(bar: Bar) => void' is not assignable to type 'Bar<{}>'. !!! error TS2322: Types of parameters 'bar' and 'foo' are incompatible. !!! error TS2322: Types of parameters 'bar' and 'foo' are incompatible. -!!! error TS2322: Type 'Foo' is not assignable to type 'Bar<{}>'. -!!! error TS2322: Types of parameters 'bar' and 'foo' are incompatible. -!!! error TS2322: Type 'void' is not assignable to type 'Foo'. +!!! error TS2322: Types of parameters 'bar' and 'foo' are incompatible. +!!! error TS2322: Type 'void' is not assignable to type 'Foo'. \ No newline at end of file diff --git a/tests/baselines/reference/nestedCallbackErrorNotFlattened.errors.txt b/tests/baselines/reference/nestedCallbackErrorNotFlattened.errors.txt new file mode 100644 index 00000000000..3749d3765b0 --- /dev/null +++ b/tests/baselines/reference/nestedCallbackErrorNotFlattened.errors.txt @@ -0,0 +1,20 @@ +tests/cases/compiler/nestedCallbackErrorNotFlattened.ts(6,1): error TS2322: Type '() => () => () => () => number' is not assignable to type '() => () => () => () => string'. + Call signature return types '() => () => () => number' and '() => () => () => string' are incompatible. + Call signature return types '() => () => number' and '() => () => string' are incompatible. + Call signature return types '() => number' and '() => string' are incompatible. + Type 'number' is not assignable to type 'string'. + + +==== tests/cases/compiler/nestedCallbackErrorNotFlattened.ts (1 errors) ==== + type Cb = {noAlias: () => T}["noAlias"]; // `"noAlias"` here prevents an alias symbol from being made + // which means the comparison will definitely be structural, rather than by variance + + declare const x: Cb>>>; // one more layer of `Cb` adn we'd get a `true` from the deeply-nested symbol check + declare let y: Cb>>>; + y = x; + ~ +!!! error TS2322: Type '() => () => () => () => number' is not assignable to type '() => () => () => () => string'. +!!! error TS2322: Call signature return types '() => () => () => number' and '() => () => () => string' are incompatible. +!!! error TS2322: Call signature return types '() => () => number' and '() => () => string' are incompatible. +!!! error TS2322: Call signature return types '() => number' and '() => string' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/nestedCallbackErrorNotFlattened.js b/tests/baselines/reference/nestedCallbackErrorNotFlattened.js new file mode 100644 index 00000000000..0c5edf9760b --- /dev/null +++ b/tests/baselines/reference/nestedCallbackErrorNotFlattened.js @@ -0,0 +1,11 @@ +//// [nestedCallbackErrorNotFlattened.ts] +type Cb = {noAlias: () => T}["noAlias"]; // `"noAlias"` here prevents an alias symbol from being made +// which means the comparison will definitely be structural, rather than by variance + +declare const x: Cb>>>; // one more layer of `Cb` adn we'd get a `true` from the deeply-nested symbol check +declare let y: Cb>>>; +y = x; + +//// [nestedCallbackErrorNotFlattened.js] +"use strict"; +y = x; diff --git a/tests/baselines/reference/nestedCallbackErrorNotFlattened.symbols b/tests/baselines/reference/nestedCallbackErrorNotFlattened.symbols new file mode 100644 index 00000000000..2019b787822 --- /dev/null +++ b/tests/baselines/reference/nestedCallbackErrorNotFlattened.symbols @@ -0,0 +1,27 @@ +=== tests/cases/compiler/nestedCallbackErrorNotFlattened.ts === +type Cb = {noAlias: () => T}["noAlias"]; // `"noAlias"` here prevents an alias symbol from being made +>Cb : Symbol(Cb, Decl(nestedCallbackErrorNotFlattened.ts, 0, 0)) +>T : Symbol(T, Decl(nestedCallbackErrorNotFlattened.ts, 0, 8)) +>noAlias : Symbol(noAlias, Decl(nestedCallbackErrorNotFlattened.ts, 0, 14)) +>T : Symbol(T, Decl(nestedCallbackErrorNotFlattened.ts, 0, 8)) + +// which means the comparison will definitely be structural, rather than by variance + +declare const x: Cb>>>; // one more layer of `Cb` adn we'd get a `true` from the deeply-nested symbol check +>x : Symbol(x, Decl(nestedCallbackErrorNotFlattened.ts, 3, 13)) +>Cb : Symbol(Cb, Decl(nestedCallbackErrorNotFlattened.ts, 0, 0)) +>Cb : Symbol(Cb, Decl(nestedCallbackErrorNotFlattened.ts, 0, 0)) +>Cb : Symbol(Cb, Decl(nestedCallbackErrorNotFlattened.ts, 0, 0)) +>Cb : Symbol(Cb, Decl(nestedCallbackErrorNotFlattened.ts, 0, 0)) + +declare let y: Cb>>>; +>y : Symbol(y, Decl(nestedCallbackErrorNotFlattened.ts, 4, 11)) +>Cb : Symbol(Cb, Decl(nestedCallbackErrorNotFlattened.ts, 0, 0)) +>Cb : Symbol(Cb, Decl(nestedCallbackErrorNotFlattened.ts, 0, 0)) +>Cb : Symbol(Cb, Decl(nestedCallbackErrorNotFlattened.ts, 0, 0)) +>Cb : Symbol(Cb, Decl(nestedCallbackErrorNotFlattened.ts, 0, 0)) + +y = x; +>y : Symbol(y, Decl(nestedCallbackErrorNotFlattened.ts, 4, 11)) +>x : Symbol(x, Decl(nestedCallbackErrorNotFlattened.ts, 3, 13)) + diff --git a/tests/baselines/reference/nestedCallbackErrorNotFlattened.types b/tests/baselines/reference/nestedCallbackErrorNotFlattened.types new file mode 100644 index 00000000000..5e753714b34 --- /dev/null +++ b/tests/baselines/reference/nestedCallbackErrorNotFlattened.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/nestedCallbackErrorNotFlattened.ts === +type Cb = {noAlias: () => T}["noAlias"]; // `"noAlias"` here prevents an alias symbol from being made +>Cb : () => T +>noAlias : () => T + +// which means the comparison will definitely be structural, rather than by variance + +declare const x: Cb>>>; // one more layer of `Cb` adn we'd get a `true` from the deeply-nested symbol check +>x : () => () => () => () => number + +declare let y: Cb>>>; +>y : () => () => () => () => string + +y = x; +>y = x : () => () => () => () => number +>y : () => () => () => () => string +>x : () => () => () => () => number + diff --git a/tests/baselines/reference/nestedRecursiveArraysOrObjectsError01.errors.txt b/tests/baselines/reference/nestedRecursiveArraysOrObjectsError01.errors.txt index 138a4a84158..650a808e598 100644 --- a/tests/baselines/reference/nestedRecursiveArraysOrObjectsError01.errors.txt +++ b/tests/baselines/reference/nestedRecursiveArraysOrObjectsError01.errors.txt @@ -1,17 +1,14 @@ tests/cases/compiler/nestedRecursiveArraysOrObjectsError01.ts(10,9): error TS2322: Type '{ foo: string; jj: number; }[][][]' is not assignable to type 'Style'. Type '{ foo: string; jj: number; }[][][]' is not assignable to type 'StyleArray'. - Types of property 'pop' are incompatible. - Type '() => { foo: string; jj: number; }[][]' is not assignable to type '() => Style'. - Type '{ foo: string; jj: number; }[][]' is not assignable to type 'Style'. - Type '{ foo: string; jj: number; }[][]' is not assignable to type 'StyleArray'. - Types of property 'pop' are incompatible. - Type '() => { foo: string; jj: number; }[]' is not assignable to type '() => Style'. - Type '{ foo: string; jj: number; }[]' is not assignable to type 'Style'. - Type '{ foo: string; jj: number; }[]' is not assignable to type 'StyleArray'. - Types of property 'pop' are incompatible. - Type '() => { foo: string; jj: number; }' is not assignable to type '() => Style'. - Type '{ foo: string; jj: number; }' is not assignable to type 'Style'. - Object literal may only specify known properties, and 'jj' does not exist in type 'Style'. + The types returned by 'pop()' are incompatible between these types. + Type '{ foo: string; jj: number; }[][]' is not assignable to type 'Style'. + Type '{ foo: string; jj: number; }[][]' is not assignable to type 'StyleArray'. + The types returned by 'pop()' are incompatible between these types. + Type '{ foo: string; jj: number; }[]' is not assignable to type 'Style'. + Type '{ foo: string; jj: number; }[]' is not assignable to type 'StyleArray'. + The types returned by 'pop()' are incompatible between these types. + Type '{ foo: string; jj: number; }' is not assignable to type 'Style'. + Object literal may only specify known properties, and 'jj' does not exist in type 'Style'. ==== tests/cases/compiler/nestedRecursiveArraysOrObjectsError01.ts (1 errors) ==== @@ -28,18 +25,15 @@ tests/cases/compiler/nestedRecursiveArraysOrObjectsError01.ts(10,9): error TS232 ~~~~~ !!! error TS2322: Type '{ foo: string; jj: number; }[][][]' is not assignable to type 'Style'. !!! error TS2322: Type '{ foo: string; jj: number; }[][][]' is not assignable to type 'StyleArray'. -!!! error TS2322: Types of property 'pop' are incompatible. -!!! error TS2322: Type '() => { foo: string; jj: number; }[][]' is not assignable to type '() => Style'. -!!! error TS2322: Type '{ foo: string; jj: number; }[][]' is not assignable to type 'Style'. -!!! error TS2322: Type '{ foo: string; jj: number; }[][]' is not assignable to type 'StyleArray'. -!!! error TS2322: Types of property 'pop' are incompatible. -!!! error TS2322: Type '() => { foo: string; jj: number; }[]' is not assignable to type '() => Style'. -!!! error TS2322: Type '{ foo: string; jj: number; }[]' is not assignable to type 'Style'. -!!! error TS2322: Type '{ foo: string; jj: number; }[]' is not assignable to type 'StyleArray'. -!!! error TS2322: Types of property 'pop' are incompatible. -!!! error TS2322: Type '() => { foo: string; jj: number; }' is not assignable to type '() => Style'. -!!! error TS2322: Type '{ foo: string; jj: number; }' is not assignable to type 'Style'. -!!! error TS2322: Object literal may only specify known properties, and 'jj' does not exist in type 'Style'. +!!! error TS2322: The types returned by 'pop()' are incompatible between these types. +!!! error TS2322: Type '{ foo: string; jj: number; }[][]' is not assignable to type 'Style'. +!!! error TS2322: Type '{ foo: string; jj: number; }[][]' is not assignable to type 'StyleArray'. +!!! error TS2322: The types returned by 'pop()' are incompatible between these types. +!!! error TS2322: Type '{ foo: string; jj: number; }[]' is not assignable to type 'Style'. +!!! error TS2322: Type '{ foo: string; jj: number; }[]' is not assignable to type 'StyleArray'. +!!! error TS2322: The types returned by 'pop()' are incompatible between these types. +!!! error TS2322: Type '{ foo: string; jj: number; }' is not assignable to type 'Style'. +!!! error TS2322: Object literal may only specify known properties, and 'jj' does not exist in type 'Style'. }]] ]; diff --git a/tests/baselines/reference/neverReturningFunctions1.errors.txt b/tests/baselines/reference/neverReturningFunctions1.errors.txt new file mode 100644 index 00000000000..5eb6659427c --- /dev/null +++ b/tests/baselines/reference/neverReturningFunctions1.errors.txt @@ -0,0 +1,296 @@ +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(13,5): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(19,5): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(30,5): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(36,5): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(51,5): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(57,5): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(63,5): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(77,9): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(82,9): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(89,9): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(96,13): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(101,13): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(103,9): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(105,5): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(111,9): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(112,9): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(122,9): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(127,9): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(129,5): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(139,9): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(141,5): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(148,9): error TS7027: Unreachable code detected. +tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(153,5): error TS7027: Unreachable code detected. + + +==== tests/cases/conformance/controlFlow/neverReturningFunctions1.ts (23 errors) ==== + function fail(message?: string): never { + throw new Error(message); + } + + function f01(x: string | undefined) { + if (x === undefined) fail("undefined argument"); + x.length; // string + } + + function f02(x: number): number { + if (x >= 0) return x; + fail("negative number"); + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + + function f03(x: string) { + x; // string + fail(); + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + + function f11(x: string | undefined, fail: (message?: string) => never) { + if (x === undefined) fail("undefined argument"); + x.length; // string + } + + function f12(x: number, fail: (message?: string) => never): number { + if (x >= 0) return x; + fail("negative number"); + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + + function f13(x: string, fail: (message?: string) => never) { + x; // string + fail(); + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + + namespace Debug { + export declare function fail(message?: string): never; + } + + function f21(x: string | undefined) { + if (x === undefined) Debug.fail("undefined argument"); + x.length; // string + } + + function f22(x: number): number { + if (x >= 0) return x; + Debug.fail("negative number"); + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + + function f23(x: string) { + x; // string + Debug.fail(); + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + + function f24(x: string) { + x; // string + ((Debug).fail)(); + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + + class Test { + fail(message?: string): never { + throw new Error(message); + } + f1(x: string | undefined) { + if (x === undefined) this.fail("undefined argument"); + x.length; // string + } + f2(x: number): number { + if (x >= 0) return x; + this.fail("negative number"); + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + f3(x: string) { + x; // string + this.fail(); + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + } + + function f30(x: string | number | undefined) { + if (typeof x === "string") { + fail(); + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + else { + x; // number | undefined + if (x !== undefined) { + x; // number + fail(); + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + else { + x; // undefined + fail(); + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + + function f31(x: { a: string | number }) { + if (typeof x.a === "string") { + fail(); + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + x.a; // Unreachable + ~~~~ +!!! error TS7027: Unreachable code detected. + } + x; // { a: string | number } + x.a; // number + } + + function f40(x: number) { + try { + x; + fail(); + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + finally { + x; + fail(); + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + + function f41(x: number) { + try { + x; + } + finally { + x; + fail(); + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + + function f42(x: number) { + try { + x; + fail(); + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + finally { + x; + } + x; // Unreachable + ~~ +!!! error TS7027: Unreachable code detected. + } + + // Repro from #33582 + + export interface Component { + attrName?: string; + data: T; + dependencies?: string[]; + el: any; + id: string; + multiple?: boolean; + name: string; + schema: unknown; + system: any; + + init(data?: T): void; + pause(): void; + play(): void; + remove(): void; + tick?(time: number, timeDelta: number): void; + update(oldData: T): void; + updateSchema?(): void; + + extendSchema(update: unknown): void; + flushToDOM(): void; + } + + export interface ComponentConstructor { + new (el: unknown, attrValue: string, id: string): T & Component; + prototype: T & { + name: string; + system: unknown; + play(): void; + pause(): void; + }; + } + + declare function registerComponent( + name: string, + component: ComponentDefinition + ): ComponentConstructor; + + export type ComponentDefinition = T & Partial & ThisType; + + const Component = registerComponent('test-component', { + schema: { + myProperty: { + default: [], + parse() { + return [true]; + } + }, + string: { type: 'string' }, + num: 0 + }, + init() { + this.data.num = 0; + this.el.setAttribute('custom-attribute', 'custom-value'); + }, + update() {}, + tick() {}, + remove() {}, + pause() {}, + play() {}, + + multiply(f: number) { + // Reference to system because both were registered with the same name. + return f * this.data.num * this.system!.data.counter; + } + }); + \ No newline at end of file diff --git a/tests/baselines/reference/neverReturningFunctions1.js b/tests/baselines/reference/neverReturningFunctions1.js new file mode 100644 index 00000000000..a99cc51e06d --- /dev/null +++ b/tests/baselines/reference/neverReturningFunctions1.js @@ -0,0 +1,435 @@ +//// [neverReturningFunctions1.ts] +function fail(message?: string): never { + throw new Error(message); +} + +function f01(x: string | undefined) { + if (x === undefined) fail("undefined argument"); + x.length; // string +} + +function f02(x: number): number { + if (x >= 0) return x; + fail("negative number"); + x; // Unreachable +} + +function f03(x: string) { + x; // string + fail(); + x; // Unreachable +} + +function f11(x: string | undefined, fail: (message?: string) => never) { + if (x === undefined) fail("undefined argument"); + x.length; // string +} + +function f12(x: number, fail: (message?: string) => never): number { + if (x >= 0) return x; + fail("negative number"); + x; // Unreachable +} + +function f13(x: string, fail: (message?: string) => never) { + x; // string + fail(); + x; // Unreachable +} + +namespace Debug { + export declare function fail(message?: string): never; +} + +function f21(x: string | undefined) { + if (x === undefined) Debug.fail("undefined argument"); + x.length; // string +} + +function f22(x: number): number { + if (x >= 0) return x; + Debug.fail("negative number"); + x; // Unreachable +} + +function f23(x: string) { + x; // string + Debug.fail(); + x; // Unreachable +} + +function f24(x: string) { + x; // string + ((Debug).fail)(); + x; // Unreachable +} + +class Test { + fail(message?: string): never { + throw new Error(message); + } + f1(x: string | undefined) { + if (x === undefined) this.fail("undefined argument"); + x.length; // string + } + f2(x: number): number { + if (x >= 0) return x; + this.fail("negative number"); + x; // Unreachable + } + f3(x: string) { + x; // string + this.fail(); + x; // Unreachable + } +} + +function f30(x: string | number | undefined) { + if (typeof x === "string") { + fail(); + x; // Unreachable + } + else { + x; // number | undefined + if (x !== undefined) { + x; // number + fail(); + x; // Unreachable + } + else { + x; // undefined + fail(); + x; // Unreachable + } + x; // Unreachable + } + x; // Unreachable +} + +function f31(x: { a: string | number }) { + if (typeof x.a === "string") { + fail(); + x; // Unreachable + x.a; // Unreachable + } + x; // { a: string | number } + x.a; // number +} + +function f40(x: number) { + try { + x; + fail(); + x; // Unreachable + } + finally { + x; + fail(); + x; // Unreachable + } + x; // Unreachable +} + +function f41(x: number) { + try { + x; + } + finally { + x; + fail(); + x; // Unreachable + } + x; // Unreachable +} + +function f42(x: number) { + try { + x; + fail(); + x; // Unreachable + } + finally { + x; + } + x; // Unreachable +} + +// Repro from #33582 + +export interface Component { + attrName?: string; + data: T; + dependencies?: string[]; + el: any; + id: string; + multiple?: boolean; + name: string; + schema: unknown; + system: any; + + init(data?: T): void; + pause(): void; + play(): void; + remove(): void; + tick?(time: number, timeDelta: number): void; + update(oldData: T): void; + updateSchema?(): void; + + extendSchema(update: unknown): void; + flushToDOM(): void; +} + +export interface ComponentConstructor { + new (el: unknown, attrValue: string, id: string): T & Component; + prototype: T & { + name: string; + system: unknown; + play(): void; + pause(): void; + }; +} + +declare function registerComponent( + name: string, + component: ComponentDefinition +): ComponentConstructor; + +export type ComponentDefinition = T & Partial & ThisType; + +const Component = registerComponent('test-component', { + schema: { + myProperty: { + default: [], + parse() { + return [true]; + } + }, + string: { type: 'string' }, + num: 0 + }, + init() { + this.data.num = 0; + this.el.setAttribute('custom-attribute', 'custom-value'); + }, + update() {}, + tick() {}, + remove() {}, + pause() {}, + play() {}, + + multiply(f: number) { + // Reference to system because both were registered with the same name. + return f * this.data.num * this.system!.data.counter; + } +}); + + +//// [neverReturningFunctions1.js] +"use strict"; +exports.__esModule = true; +function fail(message) { + throw new Error(message); +} +function f01(x) { + if (x === undefined) + fail("undefined argument"); + x.length; // string +} +function f02(x) { + if (x >= 0) + return x; + fail("negative number"); + x; // Unreachable +} +function f03(x) { + x; // string + fail(); + x; // Unreachable +} +function f11(x, fail) { + if (x === undefined) + fail("undefined argument"); + x.length; // string +} +function f12(x, fail) { + if (x >= 0) + return x; + fail("negative number"); + x; // Unreachable +} +function f13(x, fail) { + x; // string + fail(); + x; // Unreachable +} +var Debug; +(function (Debug) { +})(Debug || (Debug = {})); +function f21(x) { + if (x === undefined) + Debug.fail("undefined argument"); + x.length; // string +} +function f22(x) { + if (x >= 0) + return x; + Debug.fail("negative number"); + x; // Unreachable +} +function f23(x) { + x; // string + Debug.fail(); + x; // Unreachable +} +function f24(x) { + x; // string + ((Debug).fail)(); + x; // Unreachable +} +var Test = /** @class */ (function () { + function Test() { + } + Test.prototype.fail = function (message) { + throw new Error(message); + }; + Test.prototype.f1 = function (x) { + if (x === undefined) + this.fail("undefined argument"); + x.length; // string + }; + Test.prototype.f2 = function (x) { + if (x >= 0) + return x; + this.fail("negative number"); + x; // Unreachable + }; + Test.prototype.f3 = function (x) { + x; // string + this.fail(); + x; // Unreachable + }; + return Test; +}()); +function f30(x) { + if (typeof x === "string") { + fail(); + x; // Unreachable + } + else { + x; // number | undefined + if (x !== undefined) { + x; // number + fail(); + x; // Unreachable + } + else { + x; // undefined + fail(); + x; // Unreachable + } + x; // Unreachable + } + x; // Unreachable +} +function f31(x) { + if (typeof x.a === "string") { + fail(); + x; // Unreachable + x.a; // Unreachable + } + x; // { a: string | number } + x.a; // number +} +function f40(x) { + try { + x; + fail(); + x; // Unreachable + } + finally { + x; + fail(); + x; // Unreachable + } + x; // Unreachable +} +function f41(x) { + try { + x; + } + finally { + x; + fail(); + x; // Unreachable + } + x; // Unreachable +} +function f42(x) { + try { + x; + fail(); + x; // Unreachable + } + finally { + x; + } + x; // Unreachable +} +var Component = registerComponent('test-component', { + schema: { + myProperty: { + "default": [], + parse: function () { + return [true]; + } + }, + string: { type: 'string' }, + num: 0 + }, + init: function () { + this.data.num = 0; + this.el.setAttribute('custom-attribute', 'custom-value'); + }, + update: function () { }, + tick: function () { }, + remove: function () { }, + pause: function () { }, + play: function () { }, + multiply: function (f) { + // Reference to system because both were registered with the same name. + return f * this.data.num * this.system.data.counter; + } +}); + + +//// [neverReturningFunctions1.d.ts] +export interface Component { + attrName?: string; + data: T; + dependencies?: string[]; + el: any; + id: string; + multiple?: boolean; + name: string; + schema: unknown; + system: any; + init(data?: T): void; + pause(): void; + play(): void; + remove(): void; + tick?(time: number, timeDelta: number): void; + update(oldData: T): void; + updateSchema?(): void; + extendSchema(update: unknown): void; + flushToDOM(): void; +} +export interface ComponentConstructor { + new (el: unknown, attrValue: string, id: string): T & Component; + prototype: T & { + name: string; + system: unknown; + play(): void; + pause(): void; + }; +} +export declare type ComponentDefinition = T & Partial & ThisType; diff --git a/tests/baselines/reference/neverReturningFunctions1.symbols b/tests/baselines/reference/neverReturningFunctions1.symbols new file mode 100644 index 00000000000..2ec4c5f93d3 --- /dev/null +++ b/tests/baselines/reference/neverReturningFunctions1.symbols @@ -0,0 +1,580 @@ +=== tests/cases/conformance/controlFlow/neverReturningFunctions1.ts === +function fail(message?: string): never { +>fail : Symbol(fail, Decl(neverReturningFunctions1.ts, 0, 0)) +>message : Symbol(message, Decl(neverReturningFunctions1.ts, 0, 14)) + + throw new Error(message); +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>message : Symbol(message, Decl(neverReturningFunctions1.ts, 0, 14)) +} + +function f01(x: string | undefined) { +>f01 : Symbol(f01, Decl(neverReturningFunctions1.ts, 2, 1)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 4, 13)) + + if (x === undefined) fail("undefined argument"); +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 4, 13)) +>undefined : Symbol(undefined) +>fail : Symbol(fail, Decl(neverReturningFunctions1.ts, 0, 0)) + + x.length; // string +>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 4, 13)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +} + +function f02(x: number): number { +>f02 : Symbol(f02, Decl(neverReturningFunctions1.ts, 7, 1)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 9, 13)) + + if (x >= 0) return x; +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 9, 13)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 9, 13)) + + fail("negative number"); +>fail : Symbol(fail, Decl(neverReturningFunctions1.ts, 0, 0)) + + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 9, 13)) +} + +function f03(x: string) { +>f03 : Symbol(f03, Decl(neverReturningFunctions1.ts, 13, 1)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 15, 13)) + + x; // string +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 15, 13)) + + fail(); +>fail : Symbol(fail, Decl(neverReturningFunctions1.ts, 0, 0)) + + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 15, 13)) +} + +function f11(x: string | undefined, fail: (message?: string) => never) { +>f11 : Symbol(f11, Decl(neverReturningFunctions1.ts, 19, 1)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 21, 13)) +>fail : Symbol(fail, Decl(neverReturningFunctions1.ts, 21, 35)) +>message : Symbol(message, Decl(neverReturningFunctions1.ts, 21, 43)) + + if (x === undefined) fail("undefined argument"); +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 21, 13)) +>undefined : Symbol(undefined) +>fail : Symbol(fail, Decl(neverReturningFunctions1.ts, 21, 35)) + + x.length; // string +>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 21, 13)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +} + +function f12(x: number, fail: (message?: string) => never): number { +>f12 : Symbol(f12, Decl(neverReturningFunctions1.ts, 24, 1)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 26, 13)) +>fail : Symbol(fail, Decl(neverReturningFunctions1.ts, 26, 23)) +>message : Symbol(message, Decl(neverReturningFunctions1.ts, 26, 31)) + + if (x >= 0) return x; +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 26, 13)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 26, 13)) + + fail("negative number"); +>fail : Symbol(fail, Decl(neverReturningFunctions1.ts, 26, 23)) + + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 26, 13)) +} + +function f13(x: string, fail: (message?: string) => never) { +>f13 : Symbol(f13, Decl(neverReturningFunctions1.ts, 30, 1)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 32, 13)) +>fail : Symbol(fail, Decl(neverReturningFunctions1.ts, 32, 23)) +>message : Symbol(message, Decl(neverReturningFunctions1.ts, 32, 31)) + + x; // string +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 32, 13)) + + fail(); +>fail : Symbol(fail, Decl(neverReturningFunctions1.ts, 32, 23)) + + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 32, 13)) +} + +namespace Debug { +>Debug : Symbol(Debug, Decl(neverReturningFunctions1.ts, 36, 1)) + + export declare function fail(message?: string): never; +>fail : Symbol(fail, Decl(neverReturningFunctions1.ts, 38, 17)) +>message : Symbol(message, Decl(neverReturningFunctions1.ts, 39, 33)) +} + +function f21(x: string | undefined) { +>f21 : Symbol(f21, Decl(neverReturningFunctions1.ts, 40, 1)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 42, 13)) + + if (x === undefined) Debug.fail("undefined argument"); +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 42, 13)) +>undefined : Symbol(undefined) +>Debug.fail : Symbol(Debug.fail, Decl(neverReturningFunctions1.ts, 38, 17)) +>Debug : Symbol(Debug, Decl(neverReturningFunctions1.ts, 36, 1)) +>fail : Symbol(Debug.fail, Decl(neverReturningFunctions1.ts, 38, 17)) + + x.length; // string +>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 42, 13)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +} + +function f22(x: number): number { +>f22 : Symbol(f22, Decl(neverReturningFunctions1.ts, 45, 1)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 47, 13)) + + if (x >= 0) return x; +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 47, 13)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 47, 13)) + + Debug.fail("negative number"); +>Debug.fail : Symbol(Debug.fail, Decl(neverReturningFunctions1.ts, 38, 17)) +>Debug : Symbol(Debug, Decl(neverReturningFunctions1.ts, 36, 1)) +>fail : Symbol(Debug.fail, Decl(neverReturningFunctions1.ts, 38, 17)) + + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 47, 13)) +} + +function f23(x: string) { +>f23 : Symbol(f23, Decl(neverReturningFunctions1.ts, 51, 1)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 53, 13)) + + x; // string +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 53, 13)) + + Debug.fail(); +>Debug.fail : Symbol(Debug.fail, Decl(neverReturningFunctions1.ts, 38, 17)) +>Debug : Symbol(Debug, Decl(neverReturningFunctions1.ts, 36, 1)) +>fail : Symbol(Debug.fail, Decl(neverReturningFunctions1.ts, 38, 17)) + + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 53, 13)) +} + +function f24(x: string) { +>f24 : Symbol(f24, Decl(neverReturningFunctions1.ts, 57, 1)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 59, 13)) + + x; // string +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 59, 13)) + + ((Debug).fail)(); +>(Debug).fail : Symbol(Debug.fail, Decl(neverReturningFunctions1.ts, 38, 17)) +>Debug : Symbol(Debug, Decl(neverReturningFunctions1.ts, 36, 1)) +>fail : Symbol(Debug.fail, Decl(neverReturningFunctions1.ts, 38, 17)) + + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 59, 13)) +} + +class Test { +>Test : Symbol(Test, Decl(neverReturningFunctions1.ts, 63, 1)) + + fail(message?: string): never { +>fail : Symbol(Test.fail, Decl(neverReturningFunctions1.ts, 65, 12)) +>message : Symbol(message, Decl(neverReturningFunctions1.ts, 66, 9)) + + throw new Error(message); +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>message : Symbol(message, Decl(neverReturningFunctions1.ts, 66, 9)) + } + f1(x: string | undefined) { +>f1 : Symbol(Test.f1, Decl(neverReturningFunctions1.ts, 68, 5)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 69, 7)) + + if (x === undefined) this.fail("undefined argument"); +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 69, 7)) +>undefined : Symbol(undefined) +>this.fail : Symbol(Test.fail, Decl(neverReturningFunctions1.ts, 65, 12)) +>this : Symbol(Test, Decl(neverReturningFunctions1.ts, 63, 1)) +>fail : Symbol(Test.fail, Decl(neverReturningFunctions1.ts, 65, 12)) + + x.length; // string +>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 69, 7)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + } + f2(x: number): number { +>f2 : Symbol(Test.f2, Decl(neverReturningFunctions1.ts, 72, 5)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 73, 7)) + + if (x >= 0) return x; +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 73, 7)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 73, 7)) + + this.fail("negative number"); +>this.fail : Symbol(Test.fail, Decl(neverReturningFunctions1.ts, 65, 12)) +>this : Symbol(Test, Decl(neverReturningFunctions1.ts, 63, 1)) +>fail : Symbol(Test.fail, Decl(neverReturningFunctions1.ts, 65, 12)) + + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 73, 7)) + } + f3(x: string) { +>f3 : Symbol(Test.f3, Decl(neverReturningFunctions1.ts, 77, 5)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 78, 7)) + + x; // string +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 78, 7)) + + this.fail(); +>this.fail : Symbol(Test.fail, Decl(neverReturningFunctions1.ts, 65, 12)) +>this : Symbol(Test, Decl(neverReturningFunctions1.ts, 63, 1)) +>fail : Symbol(Test.fail, Decl(neverReturningFunctions1.ts, 65, 12)) + + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 78, 7)) + } +} + +function f30(x: string | number | undefined) { +>f30 : Symbol(f30, Decl(neverReturningFunctions1.ts, 83, 1)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 85, 13)) + + if (typeof x === "string") { +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 85, 13)) + + fail(); +>fail : Symbol(fail, Decl(neverReturningFunctions1.ts, 0, 0)) + + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 85, 13)) + } + else { + x; // number | undefined +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 85, 13)) + + if (x !== undefined) { +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 85, 13)) +>undefined : Symbol(undefined) + + x; // number +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 85, 13)) + + fail(); +>fail : Symbol(fail, Decl(neverReturningFunctions1.ts, 0, 0)) + + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 85, 13)) + } + else { + x; // undefined +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 85, 13)) + + fail(); +>fail : Symbol(fail, Decl(neverReturningFunctions1.ts, 0, 0)) + + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 85, 13)) + } + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 85, 13)) + } + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 85, 13)) +} + +function f31(x: { a: string | number }) { +>f31 : Symbol(f31, Decl(neverReturningFunctions1.ts, 105, 1)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 107, 13)) +>a : Symbol(a, Decl(neverReturningFunctions1.ts, 107, 17)) + + if (typeof x.a === "string") { +>x.a : Symbol(a, Decl(neverReturningFunctions1.ts, 107, 17)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 107, 13)) +>a : Symbol(a, Decl(neverReturningFunctions1.ts, 107, 17)) + + fail(); +>fail : Symbol(fail, Decl(neverReturningFunctions1.ts, 0, 0)) + + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 107, 13)) + + x.a; // Unreachable +>x.a : Symbol(a, Decl(neverReturningFunctions1.ts, 107, 17)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 107, 13)) +>a : Symbol(a, Decl(neverReturningFunctions1.ts, 107, 17)) + } + x; // { a: string | number } +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 107, 13)) + + x.a; // number +>x.a : Symbol(a, Decl(neverReturningFunctions1.ts, 107, 17)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 107, 13)) +>a : Symbol(a, Decl(neverReturningFunctions1.ts, 107, 17)) +} + +function f40(x: number) { +>f40 : Symbol(f40, Decl(neverReturningFunctions1.ts, 115, 1)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 117, 13)) + + try { + x; +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 117, 13)) + + fail(); +>fail : Symbol(fail, Decl(neverReturningFunctions1.ts, 0, 0)) + + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 117, 13)) + } + finally { + x; +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 117, 13)) + + fail(); +>fail : Symbol(fail, Decl(neverReturningFunctions1.ts, 0, 0)) + + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 117, 13)) + } + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 117, 13)) +} + +function f41(x: number) { +>f41 : Symbol(f41, Decl(neverReturningFunctions1.ts, 129, 1)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 131, 13)) + + try { + x; +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 131, 13)) + } + finally { + x; +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 131, 13)) + + fail(); +>fail : Symbol(fail, Decl(neverReturningFunctions1.ts, 0, 0)) + + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 131, 13)) + } + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 131, 13)) +} + +function f42(x: number) { +>f42 : Symbol(f42, Decl(neverReturningFunctions1.ts, 141, 1)) +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 143, 13)) + + try { + x; +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 143, 13)) + + fail(); +>fail : Symbol(fail, Decl(neverReturningFunctions1.ts, 0, 0)) + + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 143, 13)) + } + finally { + x; +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 143, 13)) + } + x; // Unreachable +>x : Symbol(x, Decl(neverReturningFunctions1.ts, 143, 13)) +} + +// Repro from #33582 + +export interface Component { +>Component : Symbol(Component, Decl(neverReturningFunctions1.ts, 153, 1)) +>T : Symbol(T, Decl(neverReturningFunctions1.ts, 157, 27)) + + attrName?: string; +>attrName : Symbol(Component.attrName, Decl(neverReturningFunctions1.ts, 157, 52)) + + data: T; +>data : Symbol(Component.data, Decl(neverReturningFunctions1.ts, 158, 19)) +>T : Symbol(T, Decl(neverReturningFunctions1.ts, 157, 27)) + + dependencies?: string[]; +>dependencies : Symbol(Component.dependencies, Decl(neverReturningFunctions1.ts, 159, 9)) + + el: any; +>el : Symbol(Component.el, Decl(neverReturningFunctions1.ts, 160, 25)) + + id: string; +>id : Symbol(Component.id, Decl(neverReturningFunctions1.ts, 161, 9)) + + multiple?: boolean; +>multiple : Symbol(Component.multiple, Decl(neverReturningFunctions1.ts, 162, 12)) + + name: string; +>name : Symbol(Component.name, Decl(neverReturningFunctions1.ts, 163, 20)) + + schema: unknown; +>schema : Symbol(Component.schema, Decl(neverReturningFunctions1.ts, 164, 14)) + + system: any; +>system : Symbol(Component.system, Decl(neverReturningFunctions1.ts, 165, 17)) + + init(data?: T): void; +>init : Symbol(Component.init, Decl(neverReturningFunctions1.ts, 166, 13)) +>data : Symbol(data, Decl(neverReturningFunctions1.ts, 168, 6)) +>T : Symbol(T, Decl(neverReturningFunctions1.ts, 157, 27)) + + pause(): void; +>pause : Symbol(Component.pause, Decl(neverReturningFunctions1.ts, 168, 22)) + + play(): void; +>play : Symbol(Component.play, Decl(neverReturningFunctions1.ts, 169, 15)) + + remove(): void; +>remove : Symbol(Component.remove, Decl(neverReturningFunctions1.ts, 170, 14)) + + tick?(time: number, timeDelta: number): void; +>tick : Symbol(Component.tick, Decl(neverReturningFunctions1.ts, 171, 16)) +>time : Symbol(time, Decl(neverReturningFunctions1.ts, 172, 7)) +>timeDelta : Symbol(timeDelta, Decl(neverReturningFunctions1.ts, 172, 20)) + + update(oldData: T): void; +>update : Symbol(Component.update, Decl(neverReturningFunctions1.ts, 172, 46)) +>oldData : Symbol(oldData, Decl(neverReturningFunctions1.ts, 173, 8)) +>T : Symbol(T, Decl(neverReturningFunctions1.ts, 157, 27)) + + updateSchema?(): void; +>updateSchema : Symbol(Component.updateSchema, Decl(neverReturningFunctions1.ts, 173, 26)) + + extendSchema(update: unknown): void; +>extendSchema : Symbol(Component.extendSchema, Decl(neverReturningFunctions1.ts, 174, 23)) +>update : Symbol(update, Decl(neverReturningFunctions1.ts, 176, 14)) + + flushToDOM(): void; +>flushToDOM : Symbol(Component.flushToDOM, Decl(neverReturningFunctions1.ts, 176, 37)) +} + +export interface ComponentConstructor { +>ComponentConstructor : Symbol(ComponentConstructor, Decl(neverReturningFunctions1.ts, 178, 1)) +>T : Symbol(T, Decl(neverReturningFunctions1.ts, 180, 38)) + + new (el: unknown, attrValue: string, id: string): T & Component; +>el : Symbol(el, Decl(neverReturningFunctions1.ts, 181, 6)) +>attrValue : Symbol(attrValue, Decl(neverReturningFunctions1.ts, 181, 18)) +>id : Symbol(id, Decl(neverReturningFunctions1.ts, 181, 37)) +>T : Symbol(T, Decl(neverReturningFunctions1.ts, 180, 38)) +>Component : Symbol(Component, Decl(neverReturningFunctions1.ts, 153, 1)) + + prototype: T & { +>prototype : Symbol(ComponentConstructor.prototype, Decl(neverReturningFunctions1.ts, 181, 65)) +>T : Symbol(T, Decl(neverReturningFunctions1.ts, 180, 38)) + + name: string; +>name : Symbol(name, Decl(neverReturningFunctions1.ts, 182, 17)) + + system: unknown; +>system : Symbol(system, Decl(neverReturningFunctions1.ts, 183, 15)) + + play(): void; +>play : Symbol(play, Decl(neverReturningFunctions1.ts, 184, 18)) + + pause(): void; +>pause : Symbol(pause, Decl(neverReturningFunctions1.ts, 185, 15)) + + }; +} + +declare function registerComponent( +>registerComponent : Symbol(registerComponent, Decl(neverReturningFunctions1.ts, 188, 1)) +>T : Symbol(T, Decl(neverReturningFunctions1.ts, 190, 35)) + + name: string, +>name : Symbol(name, Decl(neverReturningFunctions1.ts, 190, 53)) + + component: ComponentDefinition +>component : Symbol(component, Decl(neverReturningFunctions1.ts, 191, 17)) +>ComponentDefinition : Symbol(ComponentDefinition, Decl(neverReturningFunctions1.ts, 193, 27)) +>T : Symbol(T, Decl(neverReturningFunctions1.ts, 190, 35)) + +): ComponentConstructor; +>ComponentConstructor : Symbol(ComponentConstructor, Decl(neverReturningFunctions1.ts, 178, 1)) +>T : Symbol(T, Decl(neverReturningFunctions1.ts, 190, 35)) + +export type ComponentDefinition = T & Partial & ThisType; +>ComponentDefinition : Symbol(ComponentDefinition, Decl(neverReturningFunctions1.ts, 193, 27)) +>T : Symbol(T, Decl(neverReturningFunctions1.ts, 195, 32)) +>T : Symbol(T, Decl(neverReturningFunctions1.ts, 195, 32)) +>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --)) +>Component : Symbol(Component, Decl(neverReturningFunctions1.ts, 153, 1)) +>ThisType : Symbol(ThisType, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(neverReturningFunctions1.ts, 195, 32)) +>Component : Symbol(Component, Decl(neverReturningFunctions1.ts, 153, 1)) + +const Component = registerComponent('test-component', { +>Component : Symbol(Component, Decl(neverReturningFunctions1.ts, 153, 1), Decl(neverReturningFunctions1.ts, 197, 5)) +>registerComponent : Symbol(registerComponent, Decl(neverReturningFunctions1.ts, 188, 1)) + + schema: { +>schema : Symbol(schema, Decl(neverReturningFunctions1.ts, 197, 55)) + + myProperty: { +>myProperty : Symbol(myProperty, Decl(neverReturningFunctions1.ts, 198, 10)) + + default: [], +>default : Symbol(default, Decl(neverReturningFunctions1.ts, 199, 15)) + + parse() { +>parse : Symbol(parse, Decl(neverReturningFunctions1.ts, 200, 15)) + + return [true]; + } + }, + string: { type: 'string' }, +>string : Symbol(string, Decl(neverReturningFunctions1.ts, 204, 4)) +>type : Symbol(type, Decl(neverReturningFunctions1.ts, 205, 11)) + + num: 0 +>num : Symbol(num, Decl(neverReturningFunctions1.ts, 205, 29)) + + }, + init() { +>init : Symbol(init, Decl(neverReturningFunctions1.ts, 207, 3)) + + this.data.num = 0; +>this.data : Symbol(Component.data, Decl(neverReturningFunctions1.ts, 158, 19)) +>data : Symbol(Component.data, Decl(neverReturningFunctions1.ts, 158, 19)) + + this.el.setAttribute('custom-attribute', 'custom-value'); +>this.el : Symbol(Component.el, Decl(neverReturningFunctions1.ts, 160, 25)) +>el : Symbol(Component.el, Decl(neverReturningFunctions1.ts, 160, 25)) + + }, + update() {}, +>update : Symbol(update, Decl(neverReturningFunctions1.ts, 211, 3)) + + tick() {}, +>tick : Symbol(tick, Decl(neverReturningFunctions1.ts, 212, 13)) + + remove() {}, +>remove : Symbol(remove, Decl(neverReturningFunctions1.ts, 213, 11)) + + pause() {}, +>pause : Symbol(pause, Decl(neverReturningFunctions1.ts, 214, 13)) + + play() {}, +>play : Symbol(play, Decl(neverReturningFunctions1.ts, 215, 12)) + + multiply(f: number) { +>multiply : Symbol(multiply, Decl(neverReturningFunctions1.ts, 216, 11)) +>f : Symbol(f, Decl(neverReturningFunctions1.ts, 218, 10)) + + // Reference to system because both were registered with the same name. + return f * this.data.num * this.system!.data.counter; +>f : Symbol(f, Decl(neverReturningFunctions1.ts, 218, 10)) +>this.data : Symbol(Component.data, Decl(neverReturningFunctions1.ts, 158, 19)) +>data : Symbol(Component.data, Decl(neverReturningFunctions1.ts, 158, 19)) +>this.system : Symbol(Component.system, Decl(neverReturningFunctions1.ts, 165, 17)) +>system : Symbol(Component.system, Decl(neverReturningFunctions1.ts, 165, 17)) + } +}); + diff --git a/tests/baselines/reference/neverReturningFunctions1.types b/tests/baselines/reference/neverReturningFunctions1.types new file mode 100644 index 00000000000..ed49d1841b8 --- /dev/null +++ b/tests/baselines/reference/neverReturningFunctions1.types @@ -0,0 +1,641 @@ +=== tests/cases/conformance/controlFlow/neverReturningFunctions1.ts === +function fail(message?: string): never { +>fail : (message?: string | undefined) => never +>message : string | undefined + + throw new Error(message); +>new Error(message) : Error +>Error : ErrorConstructor +>message : string | undefined +} + +function f01(x: string | undefined) { +>f01 : (x: string | undefined) => void +>x : string | undefined + + if (x === undefined) fail("undefined argument"); +>x === undefined : boolean +>x : string | undefined +>undefined : undefined +>fail("undefined argument") : never +>fail : (message?: string | undefined) => never +>"undefined argument" : "undefined argument" + + x.length; // string +>x.length : number +>x : string +>length : number +} + +function f02(x: number): number { +>f02 : (x: number) => number +>x : number + + if (x >= 0) return x; +>x >= 0 : boolean +>x : number +>0 : 0 +>x : number + + fail("negative number"); +>fail("negative number") : never +>fail : (message?: string | undefined) => never +>"negative number" : "negative number" + + x; // Unreachable +>x : number +} + +function f03(x: string) { +>f03 : (x: string) => void +>x : string + + x; // string +>x : string + + fail(); +>fail() : never +>fail : (message?: string | undefined) => never + + x; // Unreachable +>x : string +} + +function f11(x: string | undefined, fail: (message?: string) => never) { +>f11 : (x: string | undefined, fail: (message?: string | undefined) => never) => void +>x : string | undefined +>fail : (message?: string | undefined) => never +>message : string | undefined + + if (x === undefined) fail("undefined argument"); +>x === undefined : boolean +>x : string | undefined +>undefined : undefined +>fail("undefined argument") : never +>fail : (message?: string | undefined) => never +>"undefined argument" : "undefined argument" + + x.length; // string +>x.length : number +>x : string +>length : number +} + +function f12(x: number, fail: (message?: string) => never): number { +>f12 : (x: number, fail: (message?: string | undefined) => never) => number +>x : number +>fail : (message?: string | undefined) => never +>message : string | undefined + + if (x >= 0) return x; +>x >= 0 : boolean +>x : number +>0 : 0 +>x : number + + fail("negative number"); +>fail("negative number") : never +>fail : (message?: string | undefined) => never +>"negative number" : "negative number" + + x; // Unreachable +>x : number +} + +function f13(x: string, fail: (message?: string) => never) { +>f13 : (x: string, fail: (message?: string | undefined) => never) => void +>x : string +>fail : (message?: string | undefined) => never +>message : string | undefined + + x; // string +>x : string + + fail(); +>fail() : never +>fail : (message?: string | undefined) => never + + x; // Unreachable +>x : string +} + +namespace Debug { +>Debug : typeof Debug + + export declare function fail(message?: string): never; +>fail : (message?: string | undefined) => never +>message : string | undefined +} + +function f21(x: string | undefined) { +>f21 : (x: string | undefined) => void +>x : string | undefined + + if (x === undefined) Debug.fail("undefined argument"); +>x === undefined : boolean +>x : string | undefined +>undefined : undefined +>Debug.fail("undefined argument") : never +>Debug.fail : (message?: string | undefined) => never +>Debug : typeof Debug +>fail : (message?: string | undefined) => never +>"undefined argument" : "undefined argument" + + x.length; // string +>x.length : number +>x : string +>length : number +} + +function f22(x: number): number { +>f22 : (x: number) => number +>x : number + + if (x >= 0) return x; +>x >= 0 : boolean +>x : number +>0 : 0 +>x : number + + Debug.fail("negative number"); +>Debug.fail("negative number") : never +>Debug.fail : (message?: string | undefined) => never +>Debug : typeof Debug +>fail : (message?: string | undefined) => never +>"negative number" : "negative number" + + x; // Unreachable +>x : number +} + +function f23(x: string) { +>f23 : (x: string) => void +>x : string + + x; // string +>x : string + + Debug.fail(); +>Debug.fail() : never +>Debug.fail : (message?: string | undefined) => never +>Debug : typeof Debug +>fail : (message?: string | undefined) => never + + x; // Unreachable +>x : string +} + +function f24(x: string) { +>f24 : (x: string) => void +>x : string + + x; // string +>x : string + + ((Debug).fail)(); +>((Debug).fail)() : never +>((Debug).fail) : (message?: string | undefined) => never +>(Debug).fail : (message?: string | undefined) => never +>(Debug) : typeof Debug +>Debug : typeof Debug +>fail : (message?: string | undefined) => never + + x; // Unreachable +>x : string +} + +class Test { +>Test : Test + + fail(message?: string): never { +>fail : (message?: string | undefined) => never +>message : string | undefined + + throw new Error(message); +>new Error(message) : Error +>Error : ErrorConstructor +>message : string | undefined + } + f1(x: string | undefined) { +>f1 : (x: string | undefined) => void +>x : string | undefined + + if (x === undefined) this.fail("undefined argument"); +>x === undefined : boolean +>x : string | undefined +>undefined : undefined +>this.fail("undefined argument") : never +>this.fail : (message?: string | undefined) => never +>this : this +>fail : (message?: string | undefined) => never +>"undefined argument" : "undefined argument" + + x.length; // string +>x.length : number +>x : string +>length : number + } + f2(x: number): number { +>f2 : (x: number) => number +>x : number + + if (x >= 0) return x; +>x >= 0 : boolean +>x : number +>0 : 0 +>x : number + + this.fail("negative number"); +>this.fail("negative number") : never +>this.fail : (message?: string | undefined) => never +>this : this +>fail : (message?: string | undefined) => never +>"negative number" : "negative number" + + x; // Unreachable +>x : number + } + f3(x: string) { +>f3 : (x: string) => void +>x : string + + x; // string +>x : string + + this.fail(); +>this.fail() : never +>this.fail : (message?: string | undefined) => never +>this : this +>fail : (message?: string | undefined) => never + + x; // Unreachable +>x : string + } +} + +function f30(x: string | number | undefined) { +>f30 : (x: string | number | undefined) => void +>x : string | number | undefined + + if (typeof x === "string") { +>typeof x === "string" : boolean +>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x : string | number | undefined +>"string" : "string" + + fail(); +>fail() : never +>fail : (message?: string | undefined) => never + + x; // Unreachable +>x : string | number | undefined + } + else { + x; // number | undefined +>x : number | undefined + + if (x !== undefined) { +>x !== undefined : boolean +>x : number | undefined +>undefined : undefined + + x; // number +>x : number + + fail(); +>fail() : never +>fail : (message?: string | undefined) => never + + x; // Unreachable +>x : string | number | undefined + } + else { + x; // undefined +>x : undefined + + fail(); +>fail() : never +>fail : (message?: string | undefined) => never + + x; // Unreachable +>x : string | number | undefined + } + x; // Unreachable +>x : string | number | undefined + } + x; // Unreachable +>x : string | number | undefined +} + +function f31(x: { a: string | number }) { +>f31 : (x: { a: string | number; }) => void +>x : { a: string | number; } +>a : string | number + + if (typeof x.a === "string") { +>typeof x.a === "string" : boolean +>typeof x.a : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>x.a : string | number +>x : { a: string | number; } +>a : string | number +>"string" : "string" + + fail(); +>fail() : never +>fail : (message?: string | undefined) => never + + x; // Unreachable +>x : { a: string | number; } + + x.a; // Unreachable +>x.a : string | number +>x : { a: string | number; } +>a : string | number + } + x; // { a: string | number } +>x : { a: string | number; } + + x.a; // number +>x.a : number +>x : { a: string | number; } +>a : number +} + +function f40(x: number) { +>f40 : (x: number) => void +>x : number + + try { + x; +>x : number + + fail(); +>fail() : never +>fail : (message?: string | undefined) => never + + x; // Unreachable +>x : number + } + finally { + x; +>x : number + + fail(); +>fail() : never +>fail : (message?: string | undefined) => never + + x; // Unreachable +>x : number + } + x; // Unreachable +>x : number +} + +function f41(x: number) { +>f41 : (x: number) => void +>x : number + + try { + x; +>x : number + } + finally { + x; +>x : number + + fail(); +>fail() : never +>fail : (message?: string | undefined) => never + + x; // Unreachable +>x : number + } + x; // Unreachable +>x : number +} + +function f42(x: number) { +>f42 : (x: number) => void +>x : number + + try { + x; +>x : number + + fail(); +>fail() : never +>fail : (message?: string | undefined) => never + + x; // Unreachable +>x : number + } + finally { + x; +>x : number + } + x; // Unreachable +>x : number +} + +// Repro from #33582 + +export interface Component { + attrName?: string; +>attrName : string | undefined + + data: T; +>data : T + + dependencies?: string[]; +>dependencies : string[] | undefined + + el: any; +>el : any + + id: string; +>id : string + + multiple?: boolean; +>multiple : boolean | undefined + + name: string; +>name : string + + schema: unknown; +>schema : unknown + + system: any; +>system : any + + init(data?: T): void; +>init : (data?: T | undefined) => void +>data : T | undefined + + pause(): void; +>pause : () => void + + play(): void; +>play : () => void + + remove(): void; +>remove : () => void + + tick?(time: number, timeDelta: number): void; +>tick : ((time: number, timeDelta: number) => void) | undefined +>time : number +>timeDelta : number + + update(oldData: T): void; +>update : (oldData: T) => void +>oldData : T + + updateSchema?(): void; +>updateSchema : (() => void) | undefined + + extendSchema(update: unknown): void; +>extendSchema : (update: unknown) => void +>update : unknown + + flushToDOM(): void; +>flushToDOM : () => void +} + +export interface ComponentConstructor { + new (el: unknown, attrValue: string, id: string): T & Component; +>el : unknown +>attrValue : string +>id : string + + prototype: T & { +>prototype : T & { name: string; system: unknown; play(): void; pause(): void; } + + name: string; +>name : string + + system: unknown; +>system : unknown + + play(): void; +>play : () => void + + pause(): void; +>pause : () => void + + }; +} + +declare function registerComponent( +>registerComponent : (name: string, component: ComponentDefinition) => ComponentConstructor + + name: string, +>name : string + + component: ComponentDefinition +>component : ComponentDefinition + +): ComponentConstructor; + +export type ComponentDefinition = T & Partial & ThisType; +>ComponentDefinition : ComponentDefinition + +const Component = registerComponent('test-component', { +>Component : ComponentConstructor<{ schema: { myProperty: { default: never[]; parse(): boolean[]; }; string: { type: string; }; num: number; }; init(): void; update(): void; tick(): void; remove(): void; pause(): void; play(): void; multiply(f: number): number; }> +>registerComponent('test-component', { schema: { myProperty: { default: [], parse() { return [true]; } }, string: { type: 'string' }, num: 0 }, init() { this.data.num = 0; this.el.setAttribute('custom-attribute', 'custom-value'); }, update() {}, tick() {}, remove() {}, pause() {}, play() {}, multiply(f: number) { // Reference to system because both were registered with the same name. return f * this.data.num * this.system!.data.counter; }}) : ComponentConstructor<{ schema: { myProperty: { default: never[]; parse(): boolean[]; }; string: { type: string; }; num: number; }; init(): void; update(): void; tick(): void; remove(): void; pause(): void; play(): void; multiply(f: number): number; }> +>registerComponent : (name: string, component: ComponentDefinition) => ComponentConstructor +>'test-component' : "test-component" +>{ schema: { myProperty: { default: [], parse() { return [true]; } }, string: { type: 'string' }, num: 0 }, init() { this.data.num = 0; this.el.setAttribute('custom-attribute', 'custom-value'); }, update() {}, tick() {}, remove() {}, pause() {}, play() {}, multiply(f: number) { // Reference to system because both were registered with the same name. return f * this.data.num * this.system!.data.counter; }} : { schema: { myProperty: { default: never[]; parse(): boolean[]; }; string: { type: string; }; num: number; }; init(): void; update(): void; tick(): void; remove(): void; pause(): void; play(): void; multiply(f: number): number; } + + schema: { +>schema : { myProperty: { default: never[]; parse(): boolean[]; }; string: { type: string; }; num: number; } +>{ myProperty: { default: [], parse() { return [true]; } }, string: { type: 'string' }, num: 0 } : { myProperty: { default: never[]; parse(): boolean[]; }; string: { type: string; }; num: number; } + + myProperty: { +>myProperty : { default: never[]; parse(): boolean[]; } +>{ default: [], parse() { return [true]; } } : { default: never[]; parse(): boolean[]; } + + default: [], +>default : never[] +>[] : never[] + + parse() { +>parse : () => boolean[] + + return [true]; +>[true] : true[] +>true : true + } + }, + string: { type: 'string' }, +>string : { type: string; } +>{ type: 'string' } : { type: string; } +>type : string +>'string' : "string" + + num: 0 +>num : number +>0 : 0 + + }, + init() { +>init : () => void + + this.data.num = 0; +>this.data.num = 0 : 0 +>this.data.num : any +>this.data : any +>this : { schema: { myProperty: { default: never[]; parse(): boolean[]; }; string: { type: string; }; num: number; }; init(): void; update(): void; tick(): void; remove(): void; pause(): void; play(): void; multiply(f: number): number; } & Component +>data : any +>num : any +>0 : 0 + + this.el.setAttribute('custom-attribute', 'custom-value'); +>this.el.setAttribute('custom-attribute', 'custom-value') : any +>this.el.setAttribute : any +>this.el : any +>this : { schema: { myProperty: { default: never[]; parse(): boolean[]; }; string: { type: string; }; num: number; }; init(): void; update(): void; tick(): void; remove(): void; pause(): void; play(): void; multiply(f: number): number; } & Component +>el : any +>setAttribute : any +>'custom-attribute' : "custom-attribute" +>'custom-value' : "custom-value" + + }, + update() {}, +>update : () => void + + tick() {}, +>tick : () => void + + remove() {}, +>remove : () => void + + pause() {}, +>pause : () => void + + play() {}, +>play : () => void + + multiply(f: number) { +>multiply : (f: number) => number +>f : number + + // Reference to system because both were registered with the same name. + return f * this.data.num * this.system!.data.counter; +>f * this.data.num * this.system!.data.counter : number +>f * this.data.num : number +>f : number +>this.data.num : any +>this.data : any +>this : { schema: { myProperty: { default: never[]; parse(): boolean[]; }; string: { type: string; }; num: number; }; init(): void; update(): void; tick(): void; remove(): void; pause(): void; play(): void; multiply(f: number): number; } & Component +>data : any +>num : any +>this.system!.data.counter : any +>this.system!.data : any +>this.system! : any +>this.system : any +>this : { schema: { myProperty: { default: never[]; parse(): boolean[]; }; string: { type: string; }; num: number; }; init(): void; update(): void; tick(): void; remove(): void; pause(): void; play(): void; multiply(f: number): number; } & Component +>system : any +>data : any +>counter : any + } +}); + diff --git a/tests/baselines/reference/objectTypeHidingMembersOfObjectAssignmentCompat.errors.txt b/tests/baselines/reference/objectTypeHidingMembersOfObjectAssignmentCompat.errors.txt index c4ee3ea17b2..d4afd97723e 100644 --- a/tests/baselines/reference/objectTypeHidingMembersOfObjectAssignmentCompat.errors.txt +++ b/tests/baselines/reference/objectTypeHidingMembersOfObjectAssignmentCompat.errors.txt @@ -1,15 +1,12 @@ tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat.ts(7,1): error TS2322: Type 'I' is not assignable to type 'Object'. - Types of property 'toString' are incompatible. - Type '() => void' is not assignable to type '() => string'. - Type 'void' is not assignable to type 'string'. + The types returned by 'toString()' are incompatible between these types. + Type 'void' is not assignable to type 'string'. tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat.ts(14,1): error TS2322: Type 'C' is not assignable to type 'Object'. - Types of property 'toString' are incompatible. - Type '() => void' is not assignable to type '() => string'. - Type 'void' is not assignable to type 'string'. + The types returned by 'toString()' are incompatible between these types. + Type 'void' is not assignable to type 'string'. tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat.ts(20,1): error TS2322: Type '{ toString: () => void; }' is not assignable to type 'Object'. - Types of property 'toString' are incompatible. - Type '() => void' is not assignable to type '() => string'. - Type 'void' is not assignable to type 'string'. + The types returned by 'toString()' are incompatible between these types. + Type 'void' is not assignable to type 'string'. ==== tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat.ts (3 errors) ==== @@ -22,9 +19,8 @@ tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentC o = i; // error ~ !!! error TS2322: Type 'I' is not assignable to type 'Object'. -!!! error TS2322: Types of property 'toString' are incompatible. -!!! error TS2322: Type '() => void' is not assignable to type '() => string'. -!!! error TS2322: Type 'void' is not assignable to type 'string'. +!!! error TS2322: The types returned by 'toString()' are incompatible between these types. +!!! error TS2322: Type 'void' is not assignable to type 'string'. i = o; // ok class C { @@ -34,9 +30,8 @@ tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentC o = c; // error ~ !!! error TS2322: Type 'C' is not assignable to type 'Object'. -!!! error TS2322: Types of property 'toString' are incompatible. -!!! error TS2322: Type '() => void' is not assignable to type '() => string'. -!!! error TS2322: Type 'void' is not assignable to type 'string'. +!!! error TS2322: The types returned by 'toString()' are incompatible between these types. +!!! error TS2322: Type 'void' is not assignable to type 'string'. c = o; // ok var a = { @@ -45,7 +40,6 @@ tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentC o = a; // error ~ !!! error TS2322: Type '{ toString: () => void; }' is not assignable to type 'Object'. -!!! error TS2322: Types of property 'toString' are incompatible. -!!! error TS2322: Type '() => void' is not assignable to type '() => string'. -!!! error TS2322: Type 'void' is not assignable to type 'string'. +!!! error TS2322: The types returned by 'toString()' are incompatible between these types. +!!! error TS2322: Type 'void' is not assignable to type 'string'. a = o; // ok \ No newline at end of file diff --git a/tests/baselines/reference/objectTypeHidingMembersOfObjectAssignmentCompat2.errors.txt b/tests/baselines/reference/objectTypeHidingMembersOfObjectAssignmentCompat2.errors.txt index 3e27b22240e..28d466457d7 100644 --- a/tests/baselines/reference/objectTypeHidingMembersOfObjectAssignmentCompat2.errors.txt +++ b/tests/baselines/reference/objectTypeHidingMembersOfObjectAssignmentCompat2.errors.txt @@ -1,25 +1,18 @@ tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat2.ts(7,1): error TS2322: Type 'I' is not assignable to type 'Object'. - Types of property 'toString' are incompatible. - Type '() => number' is not assignable to type '() => string'. - Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat2.ts(8,1): error TS2322: Type 'Object' is not assignable to type 'I'. - The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? - Types of property 'toString' are incompatible. - Type '() => string' is not assignable to type '() => number'. - Type 'string' is not assignable to type 'number'. + The types returned by 'toString()' are incompatible between these types. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat2.ts(8,1): error TS2696: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? + The types returned by 'toString()' are incompatible between these types. + Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat2.ts(14,1): error TS2322: Type 'C' is not assignable to type 'Object'. - Types of property 'toString' are incompatible. - Type '() => number' is not assignable to type '() => string'. - Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat2.ts(15,1): error TS2322: Type 'Object' is not assignable to type 'C'. - The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? - Types of property 'toString' are incompatible. - Type '() => string' is not assignable to type '() => number'. - Type 'string' is not assignable to type 'number'. + The types returned by 'toString()' are incompatible between these types. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat2.ts(15,1): error TS2696: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? + The types returned by 'toString()' are incompatible between these types. + Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat2.ts(20,1): error TS2322: Type '{ toString: () => void; }' is not assignable to type 'Object'. - Types of property 'toString' are incompatible. - Type '() => void' is not assignable to type '() => string'. - Type 'void' is not assignable to type 'string'. + The types returned by 'toString()' are incompatible between these types. + Type 'void' is not assignable to type 'string'. ==== tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat2.ts (5 errors) ==== @@ -32,16 +25,13 @@ tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentC o = i; // error ~ !!! error TS2322: Type 'I' is not assignable to type 'Object'. -!!! error TS2322: Types of property 'toString' are incompatible. -!!! error TS2322: Type '() => number' is not assignable to type '() => string'. -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: The types returned by 'toString()' are incompatible between these types. +!!! error TS2322: Type 'number' is not assignable to type 'string'. i = o; // error ~ -!!! error TS2322: Type 'Object' is not assignable to type 'I'. -!!! error TS2322: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? -!!! error TS2322: Types of property 'toString' are incompatible. -!!! error TS2322: Type '() => string' is not assignable to type '() => number'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2696: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? +!!! error TS2696: The types returned by 'toString()' are incompatible between these types. +!!! error TS2696: Type 'string' is not assignable to type 'number'. class C { toString(): number { return 1; } @@ -50,16 +40,13 @@ tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentC o = c; // error ~ !!! error TS2322: Type 'C' is not assignable to type 'Object'. -!!! error TS2322: Types of property 'toString' are incompatible. -!!! error TS2322: Type '() => number' is not assignable to type '() => string'. -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: The types returned by 'toString()' are incompatible between these types. +!!! error TS2322: Type 'number' is not assignable to type 'string'. c = o; // error ~ -!!! error TS2322: Type 'Object' is not assignable to type 'C'. -!!! error TS2322: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? -!!! error TS2322: Types of property 'toString' are incompatible. -!!! error TS2322: Type '() => string' is not assignable to type '() => number'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2696: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? +!!! error TS2696: The types returned by 'toString()' are incompatible between these types. +!!! error TS2696: Type 'string' is not assignable to type 'number'. var a = { toString: () => { } @@ -67,7 +54,6 @@ tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentC o = a; // error ~ !!! error TS2322: Type '{ toString: () => void; }' is not assignable to type 'Object'. -!!! error TS2322: Types of property 'toString' are incompatible. -!!! error TS2322: Type '() => void' is not assignable to type '() => string'. -!!! error TS2322: Type 'void' is not assignable to type 'string'. +!!! error TS2322: The types returned by 'toString()' are incompatible between these types. +!!! error TS2322: Type 'void' is not assignable to type 'string'. a = o; // ok \ No newline at end of file diff --git a/tests/baselines/reference/optionalTupleElements1.errors.txt b/tests/baselines/reference/optionalTupleElements1.errors.txt index ac9f5f244da..bb5fd2c01d8 100644 --- a/tests/baselines/reference/optionalTupleElements1.errors.txt +++ b/tests/baselines/reference/optionalTupleElements1.errors.txt @@ -1,25 +1,25 @@ tests/cases/conformance/types/tuple/optionalTupleElements1.ts(11,29): error TS1257: A required element cannot follow an optional element. -tests/cases/conformance/types/tuple/optionalTupleElements1.ts(15,5): error TS2322: Type '[number, string, (boolean | undefined)?]' is not assignable to type '[number, string, boolean]'. +tests/cases/conformance/types/tuple/optionalTupleElements1.ts(15,5): error TS2322: Type 'T2' is not assignable to type 'T1'. Types of property '2' are incompatible. Type 'boolean | undefined' is not assignable to type 'boolean'. Type 'undefined' is not assignable to type 'boolean'. -tests/cases/conformance/types/tuple/optionalTupleElements1.ts(16,5): error TS2322: Type '[number, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, boolean]'. +tests/cases/conformance/types/tuple/optionalTupleElements1.ts(16,5): error TS2322: Type 'T3' is not assignable to type 'T1'. Types of property '1' are incompatible. Type 'string | undefined' is not assignable to type 'string'. Type 'undefined' is not assignable to type 'string'. -tests/cases/conformance/types/tuple/optionalTupleElements1.ts(17,5): error TS2322: Type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, boolean]'. +tests/cases/conformance/types/tuple/optionalTupleElements1.ts(17,5): error TS2322: Type 'T4' is not assignable to type 'T1'. Types of property '0' are incompatible. Type 'number | undefined' is not assignable to type 'number'. Type 'undefined' is not assignable to type 'number'. -tests/cases/conformance/types/tuple/optionalTupleElements1.ts(20,5): error TS2322: Type '[number, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, (boolean | undefined)?]'. +tests/cases/conformance/types/tuple/optionalTupleElements1.ts(20,5): error TS2322: Type 'T3' is not assignable to type 'T2'. Types of property '1' are incompatible. Type 'string | undefined' is not assignable to type 'string'. Type 'undefined' is not assignable to type 'string'. -tests/cases/conformance/types/tuple/optionalTupleElements1.ts(21,5): error TS2322: Type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, (boolean | undefined)?]'. +tests/cases/conformance/types/tuple/optionalTupleElements1.ts(21,5): error TS2322: Type 'T4' is not assignable to type 'T2'. Types of property '0' are incompatible. Type 'number | undefined' is not assignable to type 'number'. Type 'undefined' is not assignable to type 'number'. -tests/cases/conformance/types/tuple/optionalTupleElements1.ts(25,5): error TS2322: Type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, (string | undefined)?, (boolean | undefined)?]'. +tests/cases/conformance/types/tuple/optionalTupleElements1.ts(25,5): error TS2322: Type 'T4' is not assignable to type 'T3'. Types of property '0' are incompatible. Type 'number | undefined' is not assignable to type 'number'. Type 'undefined' is not assignable to type 'number'. @@ -44,19 +44,19 @@ tests/cases/conformance/types/tuple/optionalTupleElements1.ts(25,5): error TS232 t1 = t1; t1 = t2; // Error ~~ -!!! error TS2322: Type '[number, string, (boolean | undefined)?]' is not assignable to type '[number, string, boolean]'. +!!! error TS2322: Type 'T2' is not assignable to type 'T1'. !!! error TS2322: Types of property '2' are incompatible. !!! error TS2322: Type 'boolean | undefined' is not assignable to type 'boolean'. !!! error TS2322: Type 'undefined' is not assignable to type 'boolean'. t1 = t3; // Error ~~ -!!! error TS2322: Type '[number, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, boolean]'. +!!! error TS2322: Type 'T3' is not assignable to type 'T1'. !!! error TS2322: Types of property '1' are incompatible. !!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. !!! error TS2322: Type 'undefined' is not assignable to type 'string'. t1 = t4; // Error ~~ -!!! error TS2322: Type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, boolean]'. +!!! error TS2322: Type 'T4' is not assignable to type 'T1'. !!! error TS2322: Types of property '0' are incompatible. !!! error TS2322: Type 'number | undefined' is not assignable to type 'number'. !!! error TS2322: Type 'undefined' is not assignable to type 'number'. @@ -64,13 +64,13 @@ tests/cases/conformance/types/tuple/optionalTupleElements1.ts(25,5): error TS232 t2 = t2; t2 = t3; // Error ~~ -!!! error TS2322: Type '[number, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, (boolean | undefined)?]'. +!!! error TS2322: Type 'T3' is not assignable to type 'T2'. !!! error TS2322: Types of property '1' are incompatible. !!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. !!! error TS2322: Type 'undefined' is not assignable to type 'string'. t2 = t4; // Error ~~ -!!! error TS2322: Type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, string, (boolean | undefined)?]'. +!!! error TS2322: Type 'T4' is not assignable to type 'T2'. !!! error TS2322: Types of property '0' are incompatible. !!! error TS2322: Type 'number | undefined' is not assignable to type 'number'. !!! error TS2322: Type 'undefined' is not assignable to type 'number'. @@ -79,7 +79,7 @@ tests/cases/conformance/types/tuple/optionalTupleElements1.ts(25,5): error TS232 t3 = t3; t3 = t4; // Error ~~ -!!! error TS2322: Type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' is not assignable to type '[number, (string | undefined)?, (boolean | undefined)?]'. +!!! error TS2322: Type 'T4' is not assignable to type 'T3'. !!! error TS2322: Types of property '0' are incompatible. !!! error TS2322: Type 'number | undefined' is not assignable to type 'number'. !!! error TS2322: Type 'undefined' is not assignable to type 'number'. diff --git a/tests/baselines/reference/optionalTupleElements1.types b/tests/baselines/reference/optionalTupleElements1.types index 630a54df517..b784bf72e58 100644 --- a/tests/baselines/reference/optionalTupleElements1.types +++ b/tests/baselines/reference/optionalTupleElements1.types @@ -1,15 +1,15 @@ === tests/cases/conformance/types/tuple/optionalTupleElements1.ts === type T1 = [number, string, boolean]; ->T1 : [number, string, boolean] +>T1 : T1 type T2 = [number, string, boolean?]; ->T2 : [number, string, (boolean | undefined)?] +>T2 : T2 type T3 = [number, string?, boolean?]; ->T3 : [number, (string | undefined)?, (boolean | undefined)?] +>T3 : T3 type T4 = [number?, string?, boolean?]; ->T4 : [(number | undefined)?, (string | undefined)?, (boolean | undefined)?] +>T4 : T4 type L1 = T1["length"]; >L1 : 3 @@ -24,122 +24,122 @@ type L4 = T4["length"]; >L4 : 0 | 3 | 2 | 1 type T5 = [number, string?, boolean]; // Error ->T5 : [number, string | undefined, boolean] +>T5 : T5 function f1(t1: T1, t2: T2, t3: T3, t4: T4) { ->f1 : (t1: [number, string, boolean], t2: [number, string, (boolean | undefined)?], t3: [number, (string | undefined)?, (boolean | undefined)?], t4: [(number | undefined)?, (string | undefined)?, (boolean | undefined)?]) => void ->t1 : [number, string, boolean] ->t2 : [number, string, (boolean | undefined)?] ->t3 : [number, (string | undefined)?, (boolean | undefined)?] ->t4 : [(number | undefined)?, (string | undefined)?, (boolean | undefined)?] +>f1 : (t1: T1, t2: T2, t3: T3, t4: T4) => void +>t1 : T1 +>t2 : T2 +>t3 : T3 +>t4 : T4 t1 = t1; ->t1 = t1 : [number, string, boolean] ->t1 : [number, string, boolean] ->t1 : [number, string, boolean] +>t1 = t1 : T1 +>t1 : T1 +>t1 : T1 t1 = t2; // Error ->t1 = t2 : [number, string, (boolean | undefined)?] ->t1 : [number, string, boolean] ->t2 : [number, string, (boolean | undefined)?] +>t1 = t2 : T2 +>t1 : T1 +>t2 : T2 t1 = t3; // Error ->t1 = t3 : [number, (string | undefined)?, (boolean | undefined)?] ->t1 : [number, string, boolean] ->t3 : [number, (string | undefined)?, (boolean | undefined)?] +>t1 = t3 : T3 +>t1 : T1 +>t3 : T3 t1 = t4; // Error ->t1 = t4 : [(number | undefined)?, (string | undefined)?, (boolean | undefined)?] ->t1 : [number, string, boolean] ->t4 : [(number | undefined)?, (string | undefined)?, (boolean | undefined)?] +>t1 = t4 : T4 +>t1 : T1 +>t4 : T4 t2 = t1; ->t2 = t1 : [number, string, boolean] ->t2 : [number, string, (boolean | undefined)?] ->t1 : [number, string, boolean] +>t2 = t1 : T1 +>t2 : T2 +>t1 : T1 t2 = t2; ->t2 = t2 : [number, string, (boolean | undefined)?] ->t2 : [number, string, (boolean | undefined)?] ->t2 : [number, string, (boolean | undefined)?] +>t2 = t2 : T2 +>t2 : T2 +>t2 : T2 t2 = t3; // Error ->t2 = t3 : [number, (string | undefined)?, (boolean | undefined)?] ->t2 : [number, string, (boolean | undefined)?] ->t3 : [number, (string | undefined)?, (boolean | undefined)?] +>t2 = t3 : T3 +>t2 : T2 +>t3 : T3 t2 = t4; // Error ->t2 = t4 : [(number | undefined)?, (string | undefined)?, (boolean | undefined)?] ->t2 : [number, string, (boolean | undefined)?] ->t4 : [(number | undefined)?, (string | undefined)?, (boolean | undefined)?] +>t2 = t4 : T4 +>t2 : T2 +>t4 : T4 t3 = t1; ->t3 = t1 : [number, string, boolean] ->t3 : [number, (string | undefined)?, (boolean | undefined)?] ->t1 : [number, string, boolean] +>t3 = t1 : T1 +>t3 : T3 +>t1 : T1 t3 = t2; ->t3 = t2 : [number, string, (boolean | undefined)?] ->t3 : [number, (string | undefined)?, (boolean | undefined)?] ->t2 : [number, string, (boolean | undefined)?] +>t3 = t2 : T2 +>t3 : T3 +>t2 : T2 t3 = t3; ->t3 = t3 : [number, (string | undefined)?, (boolean | undefined)?] ->t3 : [number, (string | undefined)?, (boolean | undefined)?] ->t3 : [number, (string | undefined)?, (boolean | undefined)?] +>t3 = t3 : T3 +>t3 : T3 +>t3 : T3 t3 = t4; // Error ->t3 = t4 : [(number | undefined)?, (string | undefined)?, (boolean | undefined)?] ->t3 : [number, (string | undefined)?, (boolean | undefined)?] ->t4 : [(number | undefined)?, (string | undefined)?, (boolean | undefined)?] +>t3 = t4 : T4 +>t3 : T3 +>t4 : T4 t4 = t1; ->t4 = t1 : [number, string, boolean] ->t4 : [(number | undefined)?, (string | undefined)?, (boolean | undefined)?] ->t1 : [number, string, boolean] +>t4 = t1 : T1 +>t4 : T4 +>t1 : T1 t4 = t2; ->t4 = t2 : [number, string, (boolean | undefined)?] ->t4 : [(number | undefined)?, (string | undefined)?, (boolean | undefined)?] ->t2 : [number, string, (boolean | undefined)?] +>t4 = t2 : T2 +>t4 : T4 +>t2 : T2 t4 = t3; ->t4 = t3 : [number, (string | undefined)?, (boolean | undefined)?] ->t4 : [(number | undefined)?, (string | undefined)?, (boolean | undefined)?] ->t3 : [number, (string | undefined)?, (boolean | undefined)?] +>t4 = t3 : T3 +>t4 : T4 +>t3 : T3 t4 = t4; ->t4 = t4 : [(number | undefined)?, (string | undefined)?, (boolean | undefined)?] ->t4 : [(number | undefined)?, (string | undefined)?, (boolean | undefined)?] ->t4 : [(number | undefined)?, (string | undefined)?, (boolean | undefined)?] +>t4 = t4 : T4 +>t4 : T4 +>t4 : T4 } let t2: T2; ->t2 : [number, string, (boolean | undefined)?] +>t2 : T2 let t3: T3; ->t3 : [number, (string | undefined)?, (boolean | undefined)?] +>t3 : T3 let t4: T4; ->t4 : [(number | undefined)?, (string | undefined)?, (boolean | undefined)?] +>t4 : T4 t2 = [42, "hello"]; >t2 = [42, "hello"] : [number, string] ->t2 : [number, string, (boolean | undefined)?] +>t2 : T2 >[42, "hello"] : [number, string] >42 : 42 >"hello" : "hello" t3 = [42, "hello"]; >t3 = [42, "hello"] : [number, string] ->t3 : [number, (string | undefined)?, (boolean | undefined)?] +>t3 : T3 >[42, "hello"] : [number, string] >42 : 42 >"hello" : "hello" t3 = [42,,true] >t3 = [42,,true] : [number, undefined, true] ->t3 : [number, (string | undefined)?, (boolean | undefined)?] +>t3 : T3 >[42,,true] : [number, undefined, true] >42 : 42 > : undefined @@ -147,20 +147,20 @@ t3 = [42,,true] t3 = [42]; >t3 = [42] : [number] ->t3 : [number, (string | undefined)?, (boolean | undefined)?] +>t3 : T3 >[42] : [number] >42 : 42 t4 = [42, "hello"]; >t4 = [42, "hello"] : [number, string] ->t4 : [(number | undefined)?, (string | undefined)?, (boolean | undefined)?] +>t4 : T4 >[42, "hello"] : [number, string] >42 : 42 >"hello" : "hello" t4 = [42,,true]; >t4 = [42,,true] : [number, undefined, true] ->t4 : [(number | undefined)?, (string | undefined)?, (boolean | undefined)?] +>t4 : T4 >[42,,true] : [number, undefined, true] >42 : 42 > : undefined @@ -168,7 +168,7 @@ t4 = [42,,true]; t4 = [,"hello", true]; >t4 = [,"hello", true] : [undefined, string, true] ->t4 : [(number | undefined)?, (string | undefined)?, (boolean | undefined)?] +>t4 : T4 >[,"hello", true] : [undefined, string, true] > : undefined >"hello" : "hello" @@ -176,7 +176,7 @@ t4 = [,"hello", true]; t4 = [,,true]; >t4 = [,,true] : [undefined, undefined, true] ->t4 : [(number | undefined)?, (string | undefined)?, (boolean | undefined)?] +>t4 : T4 >[,,true] : [undefined, undefined, true] > : undefined > : undefined @@ -184,6 +184,6 @@ t4 = [,,true]; t4 = []; >t4 = [] : [] ->t4 : [(number | undefined)?, (string | undefined)?, (boolean | undefined)?] +>t4 : T4 >[] : [] diff --git a/tests/baselines/reference/promisePermutations.errors.txt b/tests/baselines/reference/promisePermutations.errors.txt index 1cb61562fe3..d91f6bcc52f 100644 --- a/tests/baselines/reference/promisePermutations.errors.txt +++ b/tests/baselines/reference/promisePermutations.errors.txt @@ -122,8 +122,8 @@ tests/cases/compiler/promisePermutations.ts(159,21): error TS2769: No overload m tests/cases/compiler/promisePermutations.ts(160,21): error TS2769: No overload matches this call. The last overload gave the following error. Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. - Type 'Promise' is not assignable to type 'IPromise'. - Types of property 'then' are incompatible. + Call signature return types 'Promise' and 'IPromise' are incompatible. + The types of 'then' are incompatible between these types. Type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }' is not assignable to type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }'. Types of parameters 'onfulfilled' and 'success' are incompatible. Types of parameters 'value' and 'value' are incompatible. @@ -447,7 +447,7 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2769: No overload m !!! error TS2769: The last overload gave the following error. !!! error TS2769: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. !!! error TS2769: Property 'catch' is missing in type 'IPromise' but required in type 'Promise'. -!!! related TS2728 /.ts/lib.es5.d.ts:1413:5: 'catch' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1418:5: 'catch' is declared here. !!! related TS2771 tests/cases/compiler/promisePermutations.ts:5:5: The last overload is declared here. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok @@ -481,8 +481,8 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2769: No overload m !!! error TS2769: No overload matches this call. !!! error TS2769: The last overload gave the following error. !!! error TS2769: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. -!!! error TS2769: Type 'Promise' is not assignable to type 'IPromise'. -!!! error TS2769: Types of property 'then' are incompatible. +!!! error TS2769: Call signature return types 'Promise' and 'IPromise' are incompatible. +!!! error TS2769: The types of 'then' are incompatible between these types. !!! error TS2769: Type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }' is not assignable to type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }'. !!! error TS2769: Types of parameters 'onfulfilled' and 'success' are incompatible. !!! error TS2769: Types of parameters 'value' and 'value' are incompatible. diff --git a/tests/baselines/reference/promisePermutations2.errors.txt b/tests/baselines/reference/promisePermutations2.errors.txt index d601a5049bf..a4fbd3fc00a 100644 --- a/tests/baselines/reference/promisePermutations2.errors.txt +++ b/tests/baselines/reference/promisePermutations2.errors.txt @@ -80,8 +80,8 @@ tests/cases/compiler/promisePermutations2.ts(158,21): error TS2345: Argument of Type 'Promise' is not assignable to type 'Promise'. Type 'number' is not assignable to type 'string'. tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. - Type 'Promise' is not assignable to type 'IPromise'. - Types of property 'then' are incompatible. + Call signature return types 'Promise' and 'IPromise' are incompatible. + The types of 'then' are incompatible between these types. Type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }' is not assignable to type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }'. Types of parameters 'onfulfilled' and 'success' are incompatible. Types of parameters 'value' and 'value' are incompatible. @@ -351,7 +351,7 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of ~~~~~~~~~ !!! error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. !!! error TS2345: Property 'catch' is missing in type 'IPromise' but required in type 'Promise'. -!!! related TS2728 /.ts/lib.es5.d.ts:1413:5: 'catch' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1418:5: 'catch' is declared here. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11: IPromise; @@ -376,8 +376,8 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // ok ~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. -!!! error TS2345: Type 'Promise' is not assignable to type 'IPromise'. -!!! error TS2345: Types of property 'then' are incompatible. +!!! error TS2345: Call signature return types 'Promise' and 'IPromise' are incompatible. +!!! error TS2345: The types of 'then' are incompatible between these types. !!! error TS2345: Type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }' is not assignable to type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }'. !!! error TS2345: Types of parameters 'onfulfilled' and 'success' are incompatible. !!! error TS2345: Types of parameters 'value' and 'value' are incompatible. diff --git a/tests/baselines/reference/promisePermutations3.errors.txt b/tests/baselines/reference/promisePermutations3.errors.txt index d3574d2a4c3..8fb1a16bf0c 100644 --- a/tests/baselines/reference/promisePermutations3.errors.txt +++ b/tests/baselines/reference/promisePermutations3.errors.txt @@ -101,8 +101,8 @@ tests/cases/compiler/promisePermutations3.ts(158,21): error TS2769: No overload tests/cases/compiler/promisePermutations3.ts(159,21): error TS2769: No overload matches this call. The last overload gave the following error. Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. - Type 'Promise' is not assignable to type 'IPromise'. - Types of property 'then' are incompatible. + Call signature return types 'Promise' and 'IPromise' are incompatible. + The types of 'then' are incompatible between these types. Type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }' is not assignable to type '(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise'. Types of parameters 'onfulfilled' and 'success' are incompatible. Types of parameters 'value' and 'value' are incompatible. @@ -398,7 +398,7 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of !!! error TS2769: The last overload gave the following error. !!! error TS2769: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. !!! error TS2769: Property 'catch' is missing in type 'IPromise' but required in type 'Promise'. -!!! related TS2728 /.ts/lib.es5.d.ts:1413:5: 'catch' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1418:5: 'catch' is declared here. !!! related TS2771 tests/cases/compiler/promisePermutations3.ts:7:5: The last overload is declared here. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok @@ -429,8 +429,8 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of !!! error TS2769: No overload matches this call. !!! error TS2769: The last overload gave the following error. !!! error TS2769: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. -!!! error TS2769: Type 'Promise' is not assignable to type 'IPromise'. -!!! error TS2769: Types of property 'then' are incompatible. +!!! error TS2769: Call signature return types 'Promise' and 'IPromise' are incompatible. +!!! error TS2769: The types of 'then' are incompatible between these types. !!! error TS2769: Type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }' is not assignable to type '(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise'. !!! error TS2769: Types of parameters 'onfulfilled' and 'success' are incompatible. !!! error TS2769: Types of parameters 'value' and 'value' are incompatible. @@ -445,5 +445,5 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of ~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ (x: T): IPromise; (x: T, y: T): Promise; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise'. !!! error TS2345: Property 'catch' is missing in type 'IPromise' but required in type 'Promise'. -!!! related TS2728 /.ts/lib.es5.d.ts:1413:5: 'catch' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1418:5: 'catch' is declared here. var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok \ No newline at end of file diff --git a/tests/baselines/reference/promiseTypeInference.errors.txt b/tests/baselines/reference/promiseTypeInference.errors.txt index 04ba3a0d878..b04ff6f5cbc 100644 --- a/tests/baselines/reference/promiseTypeInference.errors.txt +++ b/tests/baselines/reference/promiseTypeInference.errors.txt @@ -5,10 +5,9 @@ tests/cases/compiler/promiseTypeInference.ts(10,39): error TS2769: No overload m Type 'IPromise' is not assignable to type 'number | PromiseLike'. Type 'IPromise' is not assignable to type 'PromiseLike'. Types of property 'then' are incompatible. - Type '(success?: (value: number) => IPromise) => IPromise' is not assignable to type '(onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. - Types of parameters 'success' and 'onfulfilled' are incompatible. - Type 'TResult1 | PromiseLike' is not assignable to type 'IPromise'. - Type 'TResult1' is not assignable to type 'IPromise'. + Types of parameters 'success' and 'onfulfilled' are incompatible. + Type 'TResult1 | PromiseLike' is not assignable to type 'IPromise'. + Type 'TResult1' is not assignable to type 'IPromise'. ==== tests/cases/compiler/promiseTypeInference.ts (1 errors) ==== @@ -30,11 +29,10 @@ tests/cases/compiler/promiseTypeInference.ts(10,39): error TS2769: No overload m !!! error TS2769: Type 'IPromise' is not assignable to type 'number | PromiseLike'. !!! error TS2769: Type 'IPromise' is not assignable to type 'PromiseLike'. !!! error TS2769: Types of property 'then' are incompatible. -!!! error TS2769: Type '(success?: (value: number) => IPromise) => IPromise' is not assignable to type '(onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => PromiseLike'. -!!! error TS2769: Types of parameters 'success' and 'onfulfilled' are incompatible. -!!! error TS2769: Type 'TResult1 | PromiseLike' is not assignable to type 'IPromise'. -!!! error TS2769: Type 'TResult1' is not assignable to type 'IPromise'. -!!! related TS2728 /.ts/lib.es5.d.ts:1413:5: 'catch' is declared here. +!!! error TS2769: Types of parameters 'success' and 'onfulfilled' are incompatible. +!!! error TS2769: Type 'TResult1 | PromiseLike' is not assignable to type 'IPromise'. +!!! error TS2769: Type 'TResult1' is not assignable to type 'IPromise'. +!!! related TS2728 /.ts/lib.es5.d.ts:1418:5: 'catch' is declared here. !!! related TS6502 tests/cases/compiler/promiseTypeInference.ts:2:23: The expected type comes from the return type of this signature. -!!! related TS6502 /.ts/lib.es5.d.ts:1406:57: The expected type comes from the return type of this signature. +!!! related TS6502 /.ts/lib.es5.d.ts:1411:57: The expected type comes from the return type of this signature. \ No newline at end of file diff --git a/tests/baselines/reference/reactSFCAndFunctionResolvable.types b/tests/baselines/reference/reactSFCAndFunctionResolvable.types index d8061605b1f..d4949fe8850 100644 --- a/tests/baselines/reference/reactSFCAndFunctionResolvable.types +++ b/tests/baselines/reference/reactSFCAndFunctionResolvable.types @@ -14,7 +14,7 @@ declare const OtherRadio: () => React.ReactElement<{}>; >React : any declare const Checkbox: React.SFC; ->Checkbox : React.StatelessComponent<{}> +>Checkbox : React.SFC<{}> >React : any declare const condition1: boolean; @@ -27,43 +27,43 @@ declare const condition3: boolean; >condition3 : boolean const RandomComponent: React.SFC = () => { ->RandomComponent : React.StatelessComponent<{}> +>RandomComponent : React.SFC<{}> >React : any >() => { const Component = condition1 ? Radio : Checkbox; const OtherComponent = condition2 ? OtherRadio : Checkbox; return condition1 ? : ;} : () => JSX.Element const Component = ->Component : React.StatelessComponent<{}> | ((props: {}) => React.ReactElement<{}>) +>Component : ((props: {}) => React.ReactElement<{}>) | React.SFC<{}> condition1 ->condition1 ? Radio : Checkbox : React.StatelessComponent<{}> | ((props: {}) => React.ReactElement<{}>) +>condition1 ? Radio : Checkbox : ((props: {}) => React.ReactElement<{}>) | React.SFC<{}> >condition1 : boolean ? Radio >Radio : (props: {}) => React.ReactElement<{}> : Checkbox; ->Checkbox : React.StatelessComponent<{}> +>Checkbox : React.SFC<{}> const OtherComponent = ->OtherComponent : React.StatelessComponent<{}> | (() => React.ReactElement<{}>) +>OtherComponent : (() => React.ReactElement<{}>) | React.SFC<{}> condition2 ->condition2 ? OtherRadio : Checkbox : React.StatelessComponent<{}> | (() => React.ReactElement<{}>) +>condition2 ? OtherRadio : Checkbox : (() => React.ReactElement<{}>) | React.SFC<{}> >condition2 : boolean ? OtherRadio >OtherRadio : () => React.ReactElement<{}> : Checkbox; ->Checkbox : React.StatelessComponent<{}> +>Checkbox : React.SFC<{}> return condition1 ? : ; >condition1 ? : : JSX.Element >condition1 : boolean > : JSX.Element ->Component : React.StatelessComponent<{}> | ((props: {}) => React.ReactElement<{}>) +>Component : ((props: {}) => React.ReactElement<{}>) | React.SFC<{}> > : JSX.Element ->OtherComponent : React.StatelessComponent<{}> | (() => React.ReactElement<{}>) +>OtherComponent : (() => React.ReactElement<{}>) | React.SFC<{}> }; diff --git a/tests/baselines/reference/readonlyArraysAndTuples.types b/tests/baselines/reference/readonlyArraysAndTuples.types index 5075319ef95..a0db326f35e 100644 --- a/tests/baselines/reference/readonlyArraysAndTuples.types +++ b/tests/baselines/reference/readonlyArraysAndTuples.types @@ -1,18 +1,18 @@ === tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts === type T10 = string[]; ->T10 : string[] +>T10 : T10 type T11 = Array; ->T11 : string[] +>T11 : T11 type T12 = readonly string[]; >T12 : readonly string[] type T13 = ReadonlyArray; ->T13 : readonly string[] +>T13 : T13 type T20 = [number, number]; ->T20 : [number, number] +>T20 : T20 type T21 = readonly [number, number]; >T21 : readonly [number, number] diff --git a/tests/baselines/reference/readonlyArraysAndTuples2.types b/tests/baselines/reference/readonlyArraysAndTuples2.types index 9e49820fdbe..be75e046528 100644 --- a/tests/baselines/reference/readonlyArraysAndTuples2.types +++ b/tests/baselines/reference/readonlyArraysAndTuples2.types @@ -1,18 +1,18 @@ === tests/cases/conformance/types/tuple/readonlyArraysAndTuples2.ts === type T10 = string[]; ->T10 : string[] +>T10 : T10 type T11 = Array; ->T11 : string[] +>T11 : T11 type T12 = readonly string[]; >T12 : readonly string[] type T13 = ReadonlyArray; ->T13 : readonly string[] +>T13 : T13 type T20 = [number, number]; ->T20 : [number, number] +>T20 : T20 type T21 = readonly [number, number]; >T21 : readonly [number, number] diff --git a/tests/baselines/reference/recursiveMappedTypes.types b/tests/baselines/reference/recursiveMappedTypes.types index 34cfd2d6100..02a555cdcb1 100644 --- a/tests/baselines/reference/recursiveMappedTypes.types +++ b/tests/baselines/reference/recursiveMappedTypes.types @@ -25,10 +25,10 @@ export type Circular = {[P in keyof T]: Circular}; >Circular : Circular type tup = [number, number, number, number]; ->tup : [number, number, number, number] +>tup : tup function foo(arg: Circular): tup { ->foo : (arg: any) => [number, number, number, number] +>foo : (arg: any) => tup >arg : any return arg; @@ -44,10 +44,10 @@ type DeepMap = { }; type tpl = [string, [string, [string]]]; ->tpl : [string, [string, [string]]] +>tpl : tpl type arr = string[][]; ->arr : string[][] +>arr : arr type t1 = DeepMap; // [number, [number, [number]]] >t1 : [number, [number, [number]]] diff --git a/tests/baselines/reference/recursiveTypeReferences1.errors.txt b/tests/baselines/reference/recursiveTypeReferences1.errors.txt new file mode 100644 index 00000000000..694f66b7128 --- /dev/null +++ b/tests/baselines/reference/recursiveTypeReferences1.errors.txt @@ -0,0 +1,95 @@ +tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeReferences1.ts(45,7): error TS2322: Type '42' is not assignable to type 'Box2'. +tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeReferences1.ts(60,7): error TS2322: Type 'number' is not assignable to type 'string | RecArray'. +tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeReferences1.ts(66,8): error TS2322: Type 'number' is not assignable to type 'string | string[]'. +tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeReferences1.ts(72,8): error TS2322: Type 'number' is not assignable to type 'string | (string | string[])[]'. + + +==== tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeReferences1.ts (4 errors) ==== + type ValueOrArray = T | Array>; + + const a0: ValueOrArray = 1; + const a1: ValueOrArray = [1, [2, 3], [4, [5, [6, 7]]]]; + + type HypertextNode = string | [string, { [key: string]: unknown }, ...HypertextNode[]]; + + const hypertextNode: HypertextNode = + ["div", { id: "parent" }, + ["div", { id: "first-child" }, "I'm the first child"], + ["div", { id: "second-child" }, "I'm the second child"] + ]; + + type Json = string | number | boolean | null | Json[] | { [key: string]: Json }; + + let data: Json = { + caption: "Test", + location: { x: 10, y: 20 }, + values: [true, [10, 20], null] + }; + + interface Box { value: T }; + + type T1 = Box; + type T2 = Box>; + type T3 = Box>>; + + function f1(t1: T1, t2: T2, t3: T3) { + t1 = t2; + t1 = t3; + t2 = t1; + t2 = t3; + t3 = t1; + t3 = t2; + } + + type Box1 = Box | number; + + const b10: Box1 = 42; + const b11: Box1 = { value: 42 }; + const b12: Box1 = { value: { value: { value: 42 }}}; + + type Box2 = Box; + + const b20: Box2 = 42; // Error + ~~~ +!!! error TS2322: Type '42' is not assignable to type 'Box2'. + const b21: Box2 = { value: 42 }; + const b22: Box2 = { value: { value: { value: 42 }}}; + + type RecArray = Array>; + + declare function flat(a: RecArray): Array; + declare function flat1(a: Array>): Array + declare function flat2(a: Array>>): Array; + + flat([1, [2, [3]]]); // number[] + flat([[[0]]]); // number[] + flat([[[[[[[[[[[4]]]]]]]]]]]); // number[] + flat([1, 'a', [2]]); // (string | number)[] + flat([1, [2, 'a']]); // (string | number)[] + flat([1, ['a']]); // Error + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string | RecArray'. + + flat1([1, [2, [3]]]); // (number | number[])[] + flat1([[[0]]]); // number[][] + flat1([1, 'a', [2]]); // (string | number)[] + flat1([1, [2, 'a']]); // (string | number)[] + flat1([1, ['a']]); // Error + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string | string[]'. + + flat2([1, [2, [3]]]); // number[] + flat2([[[0]]]); // number[] + flat2([1, 'a', [2]]); // (string | number)[] + flat2([1, [2, 'a']]); // (string | number)[] + flat2([1, ['a']]); // Error + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string | (string | string[])[]'. + + type T10 = T10[]; + type T11 = readonly T11[]; + type T12 = (T12)[]; + type T13 = T13[] | string; + type T14 = T14[] & { x: string }; + type T15 = X extends string ? T15[] : never; + \ No newline at end of file diff --git a/tests/baselines/reference/recursiveTypeReferences1.js b/tests/baselines/reference/recursiveTypeReferences1.js new file mode 100644 index 00000000000..ac1280f543d --- /dev/null +++ b/tests/baselines/reference/recursiveTypeReferences1.js @@ -0,0 +1,167 @@ +//// [recursiveTypeReferences1.ts] +type ValueOrArray = T | Array>; + +const a0: ValueOrArray = 1; +const a1: ValueOrArray = [1, [2, 3], [4, [5, [6, 7]]]]; + +type HypertextNode = string | [string, { [key: string]: unknown }, ...HypertextNode[]]; + +const hypertextNode: HypertextNode = + ["div", { id: "parent" }, + ["div", { id: "first-child" }, "I'm the first child"], + ["div", { id: "second-child" }, "I'm the second child"] + ]; + +type Json = string | number | boolean | null | Json[] | { [key: string]: Json }; + +let data: Json = { + caption: "Test", + location: { x: 10, y: 20 }, + values: [true, [10, 20], null] +}; + +interface Box { value: T }; + +type T1 = Box; +type T2 = Box>; +type T3 = Box>>; + +function f1(t1: T1, t2: T2, t3: T3) { + t1 = t2; + t1 = t3; + t2 = t1; + t2 = t3; + t3 = t1; + t3 = t2; +} + +type Box1 = Box | number; + +const b10: Box1 = 42; +const b11: Box1 = { value: 42 }; +const b12: Box1 = { value: { value: { value: 42 }}}; + +type Box2 = Box; + +const b20: Box2 = 42; // Error +const b21: Box2 = { value: 42 }; +const b22: Box2 = { value: { value: { value: 42 }}}; + +type RecArray = Array>; + +declare function flat(a: RecArray): Array; +declare function flat1(a: Array>): Array +declare function flat2(a: Array>>): Array; + +flat([1, [2, [3]]]); // number[] +flat([[[0]]]); // number[] +flat([[[[[[[[[[[4]]]]]]]]]]]); // number[] +flat([1, 'a', [2]]); // (string | number)[] +flat([1, [2, 'a']]); // (string | number)[] +flat([1, ['a']]); // Error + +flat1([1, [2, [3]]]); // (number | number[])[] +flat1([[[0]]]); // number[][] +flat1([1, 'a', [2]]); // (string | number)[] +flat1([1, [2, 'a']]); // (string | number)[] +flat1([1, ['a']]); // Error + +flat2([1, [2, [3]]]); // number[] +flat2([[[0]]]); // number[] +flat2([1, 'a', [2]]); // (string | number)[] +flat2([1, [2, 'a']]); // (string | number)[] +flat2([1, ['a']]); // Error + +type T10 = T10[]; +type T11 = readonly T11[]; +type T12 = (T12)[]; +type T13 = T13[] | string; +type T14 = T14[] & { x: string }; +type T15 = X extends string ? T15[] : never; + + +//// [recursiveTypeReferences1.js] +"use strict"; +var a0 = 1; +var a1 = [1, [2, 3], [4, [5, [6, 7]]]]; +var hypertextNode = ["div", { id: "parent" }, + ["div", { id: "first-child" }, "I'm the first child"], + ["div", { id: "second-child" }, "I'm the second child"] +]; +var data = { + caption: "Test", + location: { x: 10, y: 20 }, + values: [true, [10, 20], null] +}; +; +function f1(t1, t2, t3) { + t1 = t2; + t1 = t3; + t2 = t1; + t2 = t3; + t3 = t1; + t3 = t2; +} +var b10 = 42; +var b11 = { value: 42 }; +var b12 = { value: { value: { value: 42 } } }; +var b20 = 42; // Error +var b21 = { value: 42 }; +var b22 = { value: { value: { value: 42 } } }; +flat([1, [2, [3]]]); // number[] +flat([[[0]]]); // number[] +flat([[[[[[[[[[[4]]]]]]]]]]]); // number[] +flat([1, 'a', [2]]); // (string | number)[] +flat([1, [2, 'a']]); // (string | number)[] +flat([1, ['a']]); // Error +flat1([1, [2, [3]]]); // (number | number[])[] +flat1([[[0]]]); // number[][] +flat1([1, 'a', [2]]); // (string | number)[] +flat1([1, [2, 'a']]); // (string | number)[] +flat1([1, ['a']]); // Error +flat2([1, [2, [3]]]); // number[] +flat2([[[0]]]); // number[] +flat2([1, 'a', [2]]); // (string | number)[] +flat2([1, [2, 'a']]); // (string | number)[] +flat2([1, ['a']]); // Error + + +//// [recursiveTypeReferences1.d.ts] +declare type ValueOrArray = T | Array>; +declare const a0: ValueOrArray; +declare const a1: ValueOrArray; +declare type HypertextNode = string | [string, { + [key: string]: unknown; +}, ...HypertextNode[]]; +declare const hypertextNode: HypertextNode; +declare type Json = string | number | boolean | null | Json[] | { + [key: string]: Json; +}; +declare let data: Json; +interface Box { + value: T; +} +declare type T1 = Box; +declare type T2 = Box>; +declare type T3 = Box>>; +declare function f1(t1: T1, t2: T2, t3: T3): void; +declare type Box1 = Box | number; +declare const b10: Box1; +declare const b11: Box1; +declare const b12: Box1; +declare type Box2 = Box; +declare const b20: Box2; +declare const b21: Box2; +declare const b22: Box2; +declare type RecArray = Array>; +declare function flat(a: RecArray): Array; +declare function flat1(a: Array>): Array; +declare function flat2(a: Array>>): Array; +declare type T10 = T10[]; +declare type T11 = readonly T11[]; +declare type T12 = (T12)[]; +declare type T13 = T13[] | string; +declare type T14 = T14[] & { + x: string; +}; +declare type T15 = X extends string ? T15[] : never; diff --git a/tests/baselines/reference/recursiveTypeReferences1.symbols b/tests/baselines/reference/recursiveTypeReferences1.symbols new file mode 100644 index 00000000000..a3f9907971f --- /dev/null +++ b/tests/baselines/reference/recursiveTypeReferences1.symbols @@ -0,0 +1,277 @@ +=== tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeReferences1.ts === +type ValueOrArray = T | Array>; +>ValueOrArray : Symbol(ValueOrArray, Decl(recursiveTypeReferences1.ts, 0, 0)) +>T : Symbol(T, Decl(recursiveTypeReferences1.ts, 0, 18)) +>T : Symbol(T, Decl(recursiveTypeReferences1.ts, 0, 18)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>ValueOrArray : Symbol(ValueOrArray, Decl(recursiveTypeReferences1.ts, 0, 0)) +>T : Symbol(T, Decl(recursiveTypeReferences1.ts, 0, 18)) + +const a0: ValueOrArray = 1; +>a0 : Symbol(a0, Decl(recursiveTypeReferences1.ts, 2, 5)) +>ValueOrArray : Symbol(ValueOrArray, Decl(recursiveTypeReferences1.ts, 0, 0)) + +const a1: ValueOrArray = [1, [2, 3], [4, [5, [6, 7]]]]; +>a1 : Symbol(a1, Decl(recursiveTypeReferences1.ts, 3, 5)) +>ValueOrArray : Symbol(ValueOrArray, Decl(recursiveTypeReferences1.ts, 0, 0)) + +type HypertextNode = string | [string, { [key: string]: unknown }, ...HypertextNode[]]; +>HypertextNode : Symbol(HypertextNode, Decl(recursiveTypeReferences1.ts, 3, 63)) +>key : Symbol(key, Decl(recursiveTypeReferences1.ts, 5, 42)) +>HypertextNode : Symbol(HypertextNode, Decl(recursiveTypeReferences1.ts, 3, 63)) + +const hypertextNode: HypertextNode = +>hypertextNode : Symbol(hypertextNode, Decl(recursiveTypeReferences1.ts, 7, 5)) +>HypertextNode : Symbol(HypertextNode, Decl(recursiveTypeReferences1.ts, 3, 63)) + + ["div", { id: "parent" }, +>id : Symbol(id, Decl(recursiveTypeReferences1.ts, 8, 13)) + + ["div", { id: "first-child" }, "I'm the first child"], +>id : Symbol(id, Decl(recursiveTypeReferences1.ts, 9, 17)) + + ["div", { id: "second-child" }, "I'm the second child"] +>id : Symbol(id, Decl(recursiveTypeReferences1.ts, 10, 17)) + + ]; + +type Json = string | number | boolean | null | Json[] | { [key: string]: Json }; +>Json : Symbol(Json, Decl(recursiveTypeReferences1.ts, 11, 6)) +>Json : Symbol(Json, Decl(recursiveTypeReferences1.ts, 11, 6)) +>key : Symbol(key, Decl(recursiveTypeReferences1.ts, 13, 59)) +>Json : Symbol(Json, Decl(recursiveTypeReferences1.ts, 11, 6)) + +let data: Json = { +>data : Symbol(data, Decl(recursiveTypeReferences1.ts, 15, 3)) +>Json : Symbol(Json, Decl(recursiveTypeReferences1.ts, 11, 6)) + + caption: "Test", +>caption : Symbol(caption, Decl(recursiveTypeReferences1.ts, 15, 18)) + + location: { x: 10, y: 20 }, +>location : Symbol(location, Decl(recursiveTypeReferences1.ts, 16, 20)) +>x : Symbol(x, Decl(recursiveTypeReferences1.ts, 17, 15)) +>y : Symbol(y, Decl(recursiveTypeReferences1.ts, 17, 22)) + + values: [true, [10, 20], null] +>values : Symbol(values, Decl(recursiveTypeReferences1.ts, 17, 31)) + +}; + +interface Box { value: T }; +>Box : Symbol(Box, Decl(recursiveTypeReferences1.ts, 19, 2)) +>T : Symbol(T, Decl(recursiveTypeReferences1.ts, 21, 14)) +>value : Symbol(Box.value, Decl(recursiveTypeReferences1.ts, 21, 18)) +>T : Symbol(T, Decl(recursiveTypeReferences1.ts, 21, 14)) + +type T1 = Box; +>T1 : Symbol(T1, Decl(recursiveTypeReferences1.ts, 21, 30)) +>Box : Symbol(Box, Decl(recursiveTypeReferences1.ts, 19, 2)) +>T1 : Symbol(T1, Decl(recursiveTypeReferences1.ts, 21, 30)) + +type T2 = Box>; +>T2 : Symbol(T2, Decl(recursiveTypeReferences1.ts, 23, 18)) +>Box : Symbol(Box, Decl(recursiveTypeReferences1.ts, 19, 2)) +>Box : Symbol(Box, Decl(recursiveTypeReferences1.ts, 19, 2)) +>T2 : Symbol(T2, Decl(recursiveTypeReferences1.ts, 23, 18)) + +type T3 = Box>>; +>T3 : Symbol(T3, Decl(recursiveTypeReferences1.ts, 24, 23)) +>Box : Symbol(Box, Decl(recursiveTypeReferences1.ts, 19, 2)) +>Box : Symbol(Box, Decl(recursiveTypeReferences1.ts, 19, 2)) +>Box : Symbol(Box, Decl(recursiveTypeReferences1.ts, 19, 2)) +>T3 : Symbol(T3, Decl(recursiveTypeReferences1.ts, 24, 23)) + +function f1(t1: T1, t2: T2, t3: T3) { +>f1 : Symbol(f1, Decl(recursiveTypeReferences1.ts, 25, 28)) +>t1 : Symbol(t1, Decl(recursiveTypeReferences1.ts, 27, 12)) +>T1 : Symbol(T1, Decl(recursiveTypeReferences1.ts, 21, 30)) +>t2 : Symbol(t2, Decl(recursiveTypeReferences1.ts, 27, 19)) +>T2 : Symbol(T2, Decl(recursiveTypeReferences1.ts, 23, 18)) +>t3 : Symbol(t3, Decl(recursiveTypeReferences1.ts, 27, 27)) +>T3 : Symbol(T3, Decl(recursiveTypeReferences1.ts, 24, 23)) + + t1 = t2; +>t1 : Symbol(t1, Decl(recursiveTypeReferences1.ts, 27, 12)) +>t2 : Symbol(t2, Decl(recursiveTypeReferences1.ts, 27, 19)) + + t1 = t3; +>t1 : Symbol(t1, Decl(recursiveTypeReferences1.ts, 27, 12)) +>t3 : Symbol(t3, Decl(recursiveTypeReferences1.ts, 27, 27)) + + t2 = t1; +>t2 : Symbol(t2, Decl(recursiveTypeReferences1.ts, 27, 19)) +>t1 : Symbol(t1, Decl(recursiveTypeReferences1.ts, 27, 12)) + + t2 = t3; +>t2 : Symbol(t2, Decl(recursiveTypeReferences1.ts, 27, 19)) +>t3 : Symbol(t3, Decl(recursiveTypeReferences1.ts, 27, 27)) + + t3 = t1; +>t3 : Symbol(t3, Decl(recursiveTypeReferences1.ts, 27, 27)) +>t1 : Symbol(t1, Decl(recursiveTypeReferences1.ts, 27, 12)) + + t3 = t2; +>t3 : Symbol(t3, Decl(recursiveTypeReferences1.ts, 27, 27)) +>t2 : Symbol(t2, Decl(recursiveTypeReferences1.ts, 27, 19)) +} + +type Box1 = Box | number; +>Box1 : Symbol(Box1, Decl(recursiveTypeReferences1.ts, 34, 1)) +>Box : Symbol(Box, Decl(recursiveTypeReferences1.ts, 19, 2)) +>Box1 : Symbol(Box1, Decl(recursiveTypeReferences1.ts, 34, 1)) + +const b10: Box1 = 42; +>b10 : Symbol(b10, Decl(recursiveTypeReferences1.ts, 38, 5)) +>Box1 : Symbol(Box1, Decl(recursiveTypeReferences1.ts, 34, 1)) + +const b11: Box1 = { value: 42 }; +>b11 : Symbol(b11, Decl(recursiveTypeReferences1.ts, 39, 5)) +>Box1 : Symbol(Box1, Decl(recursiveTypeReferences1.ts, 34, 1)) +>value : Symbol(value, Decl(recursiveTypeReferences1.ts, 39, 19)) + +const b12: Box1 = { value: { value: { value: 42 }}}; +>b12 : Symbol(b12, Decl(recursiveTypeReferences1.ts, 40, 5)) +>Box1 : Symbol(Box1, Decl(recursiveTypeReferences1.ts, 34, 1)) +>value : Symbol(value, Decl(recursiveTypeReferences1.ts, 40, 19)) +>value : Symbol(value, Decl(recursiveTypeReferences1.ts, 40, 28)) +>value : Symbol(value, Decl(recursiveTypeReferences1.ts, 40, 37)) + +type Box2 = Box; +>Box2 : Symbol(Box2, Decl(recursiveTypeReferences1.ts, 40, 52)) +>Box : Symbol(Box, Decl(recursiveTypeReferences1.ts, 19, 2)) +>Box2 : Symbol(Box2, Decl(recursiveTypeReferences1.ts, 40, 52)) + +const b20: Box2 = 42; // Error +>b20 : Symbol(b20, Decl(recursiveTypeReferences1.ts, 44, 5)) +>Box2 : Symbol(Box2, Decl(recursiveTypeReferences1.ts, 40, 52)) + +const b21: Box2 = { value: 42 }; +>b21 : Symbol(b21, Decl(recursiveTypeReferences1.ts, 45, 5)) +>Box2 : Symbol(Box2, Decl(recursiveTypeReferences1.ts, 40, 52)) +>value : Symbol(value, Decl(recursiveTypeReferences1.ts, 45, 19)) + +const b22: Box2 = { value: { value: { value: 42 }}}; +>b22 : Symbol(b22, Decl(recursiveTypeReferences1.ts, 46, 5)) +>Box2 : Symbol(Box2, Decl(recursiveTypeReferences1.ts, 40, 52)) +>value : Symbol(value, Decl(recursiveTypeReferences1.ts, 46, 19)) +>value : Symbol(value, Decl(recursiveTypeReferences1.ts, 46, 28)) +>value : Symbol(value, Decl(recursiveTypeReferences1.ts, 46, 37)) + +type RecArray = Array>; +>RecArray : Symbol(RecArray, Decl(recursiveTypeReferences1.ts, 46, 52)) +>T : Symbol(T, Decl(recursiveTypeReferences1.ts, 48, 14)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(recursiveTypeReferences1.ts, 48, 14)) +>RecArray : Symbol(RecArray, Decl(recursiveTypeReferences1.ts, 46, 52)) +>T : Symbol(T, Decl(recursiveTypeReferences1.ts, 48, 14)) + +declare function flat(a: RecArray): Array; +>flat : Symbol(flat, Decl(recursiveTypeReferences1.ts, 48, 42)) +>T : Symbol(T, Decl(recursiveTypeReferences1.ts, 50, 22)) +>a : Symbol(a, Decl(recursiveTypeReferences1.ts, 50, 25)) +>RecArray : Symbol(RecArray, Decl(recursiveTypeReferences1.ts, 46, 52)) +>T : Symbol(T, Decl(recursiveTypeReferences1.ts, 50, 22)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(recursiveTypeReferences1.ts, 50, 22)) + +declare function flat1(a: Array>): Array +>flat1 : Symbol(flat1, Decl(recursiveTypeReferences1.ts, 50, 51)) +>T : Symbol(T, Decl(recursiveTypeReferences1.ts, 51, 23)) +>a : Symbol(a, Decl(recursiveTypeReferences1.ts, 51, 26)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(recursiveTypeReferences1.ts, 51, 23)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(recursiveTypeReferences1.ts, 51, 23)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(recursiveTypeReferences1.ts, 51, 23)) + +declare function flat2(a: Array>>): Array; +>flat2 : Symbol(flat2, Decl(recursiveTypeReferences1.ts, 51, 59)) +>T : Symbol(T, Decl(recursiveTypeReferences1.ts, 52, 23)) +>a : Symbol(a, Decl(recursiveTypeReferences1.ts, 52, 26)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(recursiveTypeReferences1.ts, 52, 23)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(recursiveTypeReferences1.ts, 52, 23)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(recursiveTypeReferences1.ts, 52, 23)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(recursiveTypeReferences1.ts, 52, 23)) + +flat([1, [2, [3]]]); // number[] +>flat : Symbol(flat, Decl(recursiveTypeReferences1.ts, 48, 42)) + +flat([[[0]]]); // number[] +>flat : Symbol(flat, Decl(recursiveTypeReferences1.ts, 48, 42)) + +flat([[[[[[[[[[[4]]]]]]]]]]]); // number[] +>flat : Symbol(flat, Decl(recursiveTypeReferences1.ts, 48, 42)) + +flat([1, 'a', [2]]); // (string | number)[] +>flat : Symbol(flat, Decl(recursiveTypeReferences1.ts, 48, 42)) + +flat([1, [2, 'a']]); // (string | number)[] +>flat : Symbol(flat, Decl(recursiveTypeReferences1.ts, 48, 42)) + +flat([1, ['a']]); // Error +>flat : Symbol(flat, Decl(recursiveTypeReferences1.ts, 48, 42)) + +flat1([1, [2, [3]]]); // (number | number[])[] +>flat1 : Symbol(flat1, Decl(recursiveTypeReferences1.ts, 50, 51)) + +flat1([[[0]]]); // number[][] +>flat1 : Symbol(flat1, Decl(recursiveTypeReferences1.ts, 50, 51)) + +flat1([1, 'a', [2]]); // (string | number)[] +>flat1 : Symbol(flat1, Decl(recursiveTypeReferences1.ts, 50, 51)) + +flat1([1, [2, 'a']]); // (string | number)[] +>flat1 : Symbol(flat1, Decl(recursiveTypeReferences1.ts, 50, 51)) + +flat1([1, ['a']]); // Error +>flat1 : Symbol(flat1, Decl(recursiveTypeReferences1.ts, 50, 51)) + +flat2([1, [2, [3]]]); // number[] +>flat2 : Symbol(flat2, Decl(recursiveTypeReferences1.ts, 51, 59)) + +flat2([[[0]]]); // number[] +>flat2 : Symbol(flat2, Decl(recursiveTypeReferences1.ts, 51, 59)) + +flat2([1, 'a', [2]]); // (string | number)[] +>flat2 : Symbol(flat2, Decl(recursiveTypeReferences1.ts, 51, 59)) + +flat2([1, [2, 'a']]); // (string | number)[] +>flat2 : Symbol(flat2, Decl(recursiveTypeReferences1.ts, 51, 59)) + +flat2([1, ['a']]); // Error +>flat2 : Symbol(flat2, Decl(recursiveTypeReferences1.ts, 51, 59)) + +type T10 = T10[]; +>T10 : Symbol(T10, Decl(recursiveTypeReferences1.ts, 71, 18)) +>T10 : Symbol(T10, Decl(recursiveTypeReferences1.ts, 71, 18)) + +type T11 = readonly T11[]; +>T11 : Symbol(T11, Decl(recursiveTypeReferences1.ts, 73, 17)) +>T11 : Symbol(T11, Decl(recursiveTypeReferences1.ts, 73, 17)) + +type T12 = (T12)[]; +>T12 : Symbol(T12, Decl(recursiveTypeReferences1.ts, 74, 26)) +>T12 : Symbol(T12, Decl(recursiveTypeReferences1.ts, 74, 26)) + +type T13 = T13[] | string; +>T13 : Symbol(T13, Decl(recursiveTypeReferences1.ts, 75, 19)) +>T13 : Symbol(T13, Decl(recursiveTypeReferences1.ts, 75, 19)) + +type T14 = T14[] & { x: string }; +>T14 : Symbol(T14, Decl(recursiveTypeReferences1.ts, 76, 26)) +>T14 : Symbol(T14, Decl(recursiveTypeReferences1.ts, 76, 26)) +>x : Symbol(x, Decl(recursiveTypeReferences1.ts, 77, 20)) + +type T15 = X extends string ? T15[] : never; +>T15 : Symbol(T15, Decl(recursiveTypeReferences1.ts, 77, 33)) +>X : Symbol(X, Decl(recursiveTypeReferences1.ts, 78, 9)) +>X : Symbol(X, Decl(recursiveTypeReferences1.ts, 78, 9)) +>T15 : Symbol(T15, Decl(recursiveTypeReferences1.ts, 77, 33)) +>X : Symbol(X, Decl(recursiveTypeReferences1.ts, 78, 9)) + diff --git a/tests/baselines/reference/recursiveTypeReferences1.types b/tests/baselines/reference/recursiveTypeReferences1.types new file mode 100644 index 00000000000..7f07f2e9c51 --- /dev/null +++ b/tests/baselines/reference/recursiveTypeReferences1.types @@ -0,0 +1,364 @@ +=== tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypeReferences1.ts === +type ValueOrArray = T | Array>; +>ValueOrArray : ValueOrArray + +const a0: ValueOrArray = 1; +>a0 : ValueOrArray +>1 : 1 + +const a1: ValueOrArray = [1, [2, 3], [4, [5, [6, 7]]]]; +>a1 : ValueOrArray +>[1, [2, 3], [4, [5, [6, 7]]]] : (number | (number | (number | number[])[])[])[] +>1 : 1 +>[2, 3] : number[] +>2 : 2 +>3 : 3 +>[4, [5, [6, 7]]] : (number | (number | number[])[])[] +>4 : 4 +>[5, [6, 7]] : (number | number[])[] +>5 : 5 +>[6, 7] : number[] +>6 : 6 +>7 : 7 + +type HypertextNode = string | [string, { [key: string]: unknown }, ...HypertextNode[]]; +>HypertextNode : HypertextNode +>key : string + +const hypertextNode: HypertextNode = +>hypertextNode : HypertextNode + + ["div", { id: "parent" }, +>["div", { id: "parent" }, ["div", { id: "first-child" }, "I'm the first child"], ["div", { id: "second-child" }, "I'm the second child"] ] : [string, { id: string; }, [string, { id: string; }, string], [string, { id: string; }, string]] +>"div" : "div" +>{ id: "parent" } : { id: string; } +>id : string +>"parent" : "parent" + + ["div", { id: "first-child" }, "I'm the first child"], +>["div", { id: "first-child" }, "I'm the first child"] : [string, { id: string; }, string] +>"div" : "div" +>{ id: "first-child" } : { id: string; } +>id : string +>"first-child" : "first-child" +>"I'm the first child" : "I'm the first child" + + ["div", { id: "second-child" }, "I'm the second child"] +>["div", { id: "second-child" }, "I'm the second child"] : [string, { id: string; }, string] +>"div" : "div" +>{ id: "second-child" } : { id: string; } +>id : string +>"second-child" : "second-child" +>"I'm the second child" : "I'm the second child" + + ]; + +type Json = string | number | boolean | null | Json[] | { [key: string]: Json }; +>Json : Json +>null : null +>key : string + +let data: Json = { +>data : Json +>{ caption: "Test", location: { x: 10, y: 20 }, values: [true, [10, 20], null]} : { caption: string; location: { x: number; y: number; }; values: (true | number[] | null)[]; } + + caption: "Test", +>caption : string +>"Test" : "Test" + + location: { x: 10, y: 20 }, +>location : { x: number; y: number; } +>{ x: 10, y: 20 } : { x: number; y: number; } +>x : number +>10 : 10 +>y : number +>20 : 20 + + values: [true, [10, 20], null] +>values : (true | number[] | null)[] +>[true, [10, 20], null] : (true | number[] | null)[] +>true : true +>[10, 20] : number[] +>10 : 10 +>20 : 20 +>null : null + +}; + +interface Box { value: T }; +>value : T + +type T1 = Box; +>T1 : T1 + +type T2 = Box>; +>T2 : T2 + +type T3 = Box>>; +>T3 : T3 + +function f1(t1: T1, t2: T2, t3: T3) { +>f1 : (t1: T1, t2: T2, t3: T3) => void +>t1 : T1 +>t2 : T2 +>t3 : T3 + + t1 = t2; +>t1 = t2 : T2 +>t1 : T1 +>t2 : T2 + + t1 = t3; +>t1 = t3 : T3 +>t1 : T1 +>t3 : T3 + + t2 = t1; +>t2 = t1 : T1 +>t2 : T2 +>t1 : T1 + + t2 = t3; +>t2 = t3 : T3 +>t2 : T2 +>t3 : T3 + + t3 = t1; +>t3 = t1 : T1 +>t3 : T3 +>t1 : T1 + + t3 = t2; +>t3 = t2 : T2 +>t3 : T3 +>t2 : T2 +} + +type Box1 = Box | number; +>Box1 : Box1 + +const b10: Box1 = 42; +>b10 : Box1 +>42 : 42 + +const b11: Box1 = { value: 42 }; +>b11 : Box1 +>{ value: 42 } : { value: number; } +>value : number +>42 : 42 + +const b12: Box1 = { value: { value: { value: 42 }}}; +>b12 : Box1 +>{ value: { value: { value: 42 }}} : { value: { value: { value: number; }; }; } +>value : { value: { value: number; }; } +>{ value: { value: 42 }} : { value: { value: number; }; } +>value : { value: number; } +>{ value: 42 } : { value: number; } +>value : number +>42 : 42 + +type Box2 = Box; +>Box2 : Box2 + +const b20: Box2 = 42; // Error +>b20 : Box2 +>42 : 42 + +const b21: Box2 = { value: 42 }; +>b21 : Box2 +>{ value: 42 } : { value: number; } +>value : number +>42 : 42 + +const b22: Box2 = { value: { value: { value: 42 }}}; +>b22 : Box2 +>{ value: { value: { value: 42 }}} : { value: { value: { value: number; }; }; } +>value : { value: { value: number; }; } +>{ value: { value: 42 }} : { value: { value: number; }; } +>value : { value: number; } +>{ value: 42 } : { value: number; } +>value : number +>42 : 42 + +type RecArray = Array>; +>RecArray : RecArray + +declare function flat(a: RecArray): Array; +>flat : (a: RecArray) => T[] +>a : RecArray + +declare function flat1(a: Array>): Array +>flat1 : (a: (T | T[])[]) => T[] +>a : (T | T[])[] + +declare function flat2(a: Array>>): Array; +>flat2 : (a: (T | (T | T[])[])[]) => T[] +>a : (T | (T | T[])[])[] + +flat([1, [2, [3]]]); // number[] +>flat([1, [2, [3]]]) : number[] +>flat : (a: RecArray) => T[] +>[1, [2, [3]]] : (number | (number | number[])[])[] +>1 : 1 +>[2, [3]] : (number | number[])[] +>2 : 2 +>[3] : number[] +>3 : 3 + +flat([[[0]]]); // number[] +>flat([[[0]]]) : number[] +>flat : (a: RecArray) => T[] +>[[[0]]] : number[][][] +>[[0]] : number[][] +>[0] : number[] +>0 : 0 + +flat([[[[[[[[[[[4]]]]]]]]]]]); // number[] +>flat([[[[[[[[[[[4]]]]]]]]]]]) : number[] +>flat : (a: RecArray) => T[] +>[[[[[[[[[[[4]]]]]]]]]]] : number[][][][][][][][][][][] +>[[[[[[[[[[4]]]]]]]]]] : number[][][][][][][][][][] +>[[[[[[[[[4]]]]]]]]] : number[][][][][][][][][] +>[[[[[[[[4]]]]]]]] : number[][][][][][][][] +>[[[[[[[4]]]]]]] : number[][][][][][][] +>[[[[[[4]]]]]] : number[][][][][][] +>[[[[[4]]]]] : number[][][][][] +>[[[[4]]]] : number[][][][] +>[[[4]]] : number[][][] +>[[4]] : number[][] +>[4] : number[] +>4 : 4 + +flat([1, 'a', [2]]); // (string | number)[] +>flat([1, 'a', [2]]) : (string | number)[] +>flat : (a: RecArray) => T[] +>[1, 'a', [2]] : (string | number | number[])[] +>1 : 1 +>'a' : "a" +>[2] : number[] +>2 : 2 + +flat([1, [2, 'a']]); // (string | number)[] +>flat([1, [2, 'a']]) : (string | number)[] +>flat : (a: RecArray) => T[] +>[1, [2, 'a']] : (number | (string | number)[])[] +>1 : 1 +>[2, 'a'] : (string | number)[] +>2 : 2 +>'a' : "a" + +flat([1, ['a']]); // Error +>flat([1, ['a']]) : any +>flat : (a: RecArray) => T[] +>[1, ['a']] : (number | string[])[] +>1 : 1 +>['a'] : string[] +>'a' : "a" + +flat1([1, [2, [3]]]); // (number | number[])[] +>flat1([1, [2, [3]]]) : (number | number[])[] +>flat1 : (a: (T | T[])[]) => T[] +>[1, [2, [3]]] : (number | (number | number[])[])[] +>1 : 1 +>[2, [3]] : (number | number[])[] +>2 : 2 +>[3] : number[] +>3 : 3 + +flat1([[[0]]]); // number[][] +>flat1([[[0]]]) : number[][] +>flat1 : (a: (T | T[])[]) => T[] +>[[[0]]] : number[][][] +>[[0]] : number[][] +>[0] : number[] +>0 : 0 + +flat1([1, 'a', [2]]); // (string | number)[] +>flat1([1, 'a', [2]]) : (string | number)[] +>flat1 : (a: (T | T[])[]) => T[] +>[1, 'a', [2]] : (string | number | number[])[] +>1 : 1 +>'a' : "a" +>[2] : number[] +>2 : 2 + +flat1([1, [2, 'a']]); // (string | number)[] +>flat1([1, [2, 'a']]) : (string | number)[] +>flat1 : (a: (T | T[])[]) => T[] +>[1, [2, 'a']] : (number | (string | number)[])[] +>1 : 1 +>[2, 'a'] : (string | number)[] +>2 : 2 +>'a' : "a" + +flat1([1, ['a']]); // Error +>flat1([1, ['a']]) : any +>flat1 : (a: (T | T[])[]) => T[] +>[1, ['a']] : (number | string[])[] +>1 : 1 +>['a'] : string[] +>'a' : "a" + +flat2([1, [2, [3]]]); // number[] +>flat2([1, [2, [3]]]) : number[] +>flat2 : (a: (T | (T | T[])[])[]) => T[] +>[1, [2, [3]]] : (number | (number | number[])[])[] +>1 : 1 +>[2, [3]] : (number | number[])[] +>2 : 2 +>[3] : number[] +>3 : 3 + +flat2([[[0]]]); // number[] +>flat2([[[0]]]) : number[] +>flat2 : (a: (T | (T | T[])[])[]) => T[] +>[[[0]]] : number[][][] +>[[0]] : number[][] +>[0] : number[] +>0 : 0 + +flat2([1, 'a', [2]]); // (string | number)[] +>flat2([1, 'a', [2]]) : (string | number)[] +>flat2 : (a: (T | (T | T[])[])[]) => T[] +>[1, 'a', [2]] : (string | number | number[])[] +>1 : 1 +>'a' : "a" +>[2] : number[] +>2 : 2 + +flat2([1, [2, 'a']]); // (string | number)[] +>flat2([1, [2, 'a']]) : (string | number)[] +>flat2 : (a: (T | (T | T[])[])[]) => T[] +>[1, [2, 'a']] : (number | (string | number)[])[] +>1 : 1 +>[2, 'a'] : (string | number)[] +>2 : 2 +>'a' : "a" + +flat2([1, ['a']]); // Error +>flat2([1, ['a']]) : any +>flat2 : (a: (T | (T | T[])[])[]) => T[] +>[1, ['a']] : (number | string[])[] +>1 : 1 +>['a'] : string[] +>'a' : "a" + +type T10 = T10[]; +>T10 : T10 + +type T11 = readonly T11[]; +>T11 : readonly (readonly (readonly (readonly (readonly (readonly (readonly (readonly (readonly (readonly (readonly any[])[])[])[])[])[])[])[])[])[])[] + +type T12 = (T12)[]; +>T12 : T12 + +type T13 = T13[] | string; +>T13 : T13 + +type T14 = T14[] & { x: string }; +>T14 : T14 +>x : string + +type T15 = X extends string ? T15[] : never; +>T15 : T15 + diff --git a/tests/baselines/reference/redefineArray.errors.txt b/tests/baselines/reference/redefineArray.errors.txt index c632915e72f..424217b1c8c 100644 --- a/tests/baselines/reference/redefineArray.errors.txt +++ b/tests/baselines/reference/redefineArray.errors.txt @@ -5,4 +5,4 @@ tests/cases/compiler/redefineArray.ts(1,1): error TS2741: Property 'isArray' is Array = function (n:number, s:string) {return n;}; ~~~~~ !!! 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 +!!! related TS2728 /.ts/lib.es5.d.ts:1369:5: 'isArray' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/restTupleElements1.types b/tests/baselines/reference/restTupleElements1.types index ffa20bf503e..88c98395f21 100644 --- a/tests/baselines/reference/restTupleElements1.types +++ b/tests/baselines/reference/restTupleElements1.types @@ -1,42 +1,42 @@ === tests/cases/conformance/types/tuple/restTupleElements1.ts === type T00 = [string?]; ->T00 : [(string | undefined)?] +>T00 : T00 type T01 = [string, string?]; ->T01 : [string, (string | undefined)?] +>T01 : T01 type T02 = [string?, string]; // Error ->T02 : [string | undefined, string] +>T02 : T02 type T03 = [...string[]]; ->T03 : string[] +>T03 : T03 type T04 = [...[...string[]]]; ->T04 : string[] +>T04 : T04 type T05 = [...[...[...string[]]]]; ->T05 : string[] +>T05 : T05 type T06 = [string, ...string[]]; ->T06 : [string, ...string[]] +>T06 : T06 type T07 = [...string[], string]; // Error ->T07 : [string[], string] +>T07 : T07 type T08 = [...string]; // Error ->T08 : string[] +>T08 : T08 type T09 = [...string?]; // Error ->T09 : (string | null)[] +>T09 : T09 type T10 = [string, ...[...string[]]]; ->T10 : [string, ...string[]] +>T10 : T10 type T11 = [string, ...[...[...string[]]]]; ->T11 : [string, ...string[]] +>T11 : T11 type T15 = [boolean, number, ...string[]]; ->T15 : [boolean, number, ...string[]] +>T15 : T15 type L15 = T15["length"]; // number >L15 : number @@ -101,7 +101,7 @@ assign<[number, ...number[]], [number, number, number, string]>(); // Error >assign : () => void type T20 = [number, string, ...boolean[]]; ->T20 : [number, string, ...boolean[]] +>T20 : T20 type T21 = T20[0]; >T21 : number @@ -128,7 +128,7 @@ type T28 = T20[number]; >T28 : string | number | boolean declare const t: T20; ->t : [number, string, ...boolean[]] +>t : T20 declare const x: number; >x : number @@ -136,31 +136,31 @@ declare const x: number; let e0 = t[0]; // number >e0 : number >t[0] : number ->t : [number, string, ...boolean[]] +>t : T20 >0 : 0 let e1 = t[1]; // string >e1 : string >t[1] : string ->t : [number, string, ...boolean[]] +>t : T20 >1 : 1 let e2 = t[2]; // boolean >e2 : boolean >t[2] : boolean ->t : [number, string, ...boolean[]] +>t : T20 >2 : 2 let e3 = t[3]; // boolean >e3 : boolean >t[3] : boolean ->t : [number, string, ...boolean[]] +>t : T20 >3 : 3 let ex = t[x]; // number | string | boolean >ex : string | number | boolean >t[x] : string | number | boolean ->t : [number, string, ...boolean[]] +>t : T20 >x : number declare function f0(x: [T, ...U[]]): [T, U]; diff --git a/tests/baselines/reference/showConfig/Shows tsconfig for single option/disableSourceOfProjectReferenceRedirect/tsconfig.json b/tests/baselines/reference/showConfig/Shows tsconfig for single option/disableSourceOfProjectReferenceRedirect/tsconfig.json new file mode 100644 index 00000000000..c8b95e0909d --- /dev/null +++ b/tests/baselines/reference/showConfig/Shows tsconfig for single option/disableSourceOfProjectReferenceRedirect/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "disableSourceOfProjectReferenceRedirect": true + } +} diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPattern.types b/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPattern.types index 8ea11e087f8..eff8a930963 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPattern.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPattern.types @@ -7,27 +7,27 @@ declare var console: { >msg : any } type Robot = [number, string, string]; ->Robot : [number, string, string] +>Robot : Robot type MultiSkilledRobot = [string, [string, string]]; ->MultiSkilledRobot : [string, [string, string]] +>MultiSkilledRobot : MultiSkilledRobot let robotA: Robot = [1, "mower", "mowing"]; ->robotA : [number, string, string] +>robotA : Robot >[1, "mower", "mowing"] : [number, string, string] >1 : 1 >"mower" : "mower" >"mowing" : "mowing" function getRobot() { ->getRobot : () => [number, string, string] +>getRobot : () => Robot return robotA; ->robotA : [number, string, string] +>robotA : Robot } let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot >["mower", ["mowing", ""]] : [string, [string, string]] >"mower" : "mower" >["mowing", ""] : [string, string] @@ -35,7 +35,7 @@ let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >"" : "" let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; ->multiRobotB : [string, [string, string]] +>multiRobotB : MultiSkilledRobot >["trimmer", ["trimming", "edging"]] : [string, [string, string]] >"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] @@ -43,16 +43,16 @@ let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; >"edging" : "edging" function getMultiRobot() { ->getMultiRobot : () => [string, [string, string]] +>getMultiRobot : () => MultiSkilledRobot return multiRobotA; ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot } for (let [, nameA] = robotA, i = 0; i < 1; i++) { > : undefined >nameA : string ->robotA : [number, string, string] +>robotA : Robot >i : number >0 : 0 >i < 1 : boolean @@ -71,8 +71,8 @@ for (let [, nameA] = robotA, i = 0; i < 1; i++) { for (let [, nameA] = getRobot(), i = 0; i < 1; i++) { > : undefined >nameA : string ->getRobot() : [number, string, string] ->getRobot : () => [number, string, string] +>getRobot() : Robot +>getRobot : () => Robot >i : number >0 : 0 >i < 1 : boolean @@ -114,7 +114,7 @@ for (let [, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0; i < 1; i++) > : undefined >primarySkillA : string >secondarySkillA : string ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot >i : number >0 : 0 >i < 1 : boolean @@ -134,8 +134,8 @@ for (let [, [primarySkillA, secondarySkillA]] = getMultiRobot(), i = 0; i < 1; i > : undefined >primarySkillA : string >secondarySkillA : string ->getMultiRobot() : [string, [string, string]] ->getMultiRobot : () => [string, [string, string]] +>getMultiRobot() : MultiSkilledRobot +>getMultiRobot : () => MultiSkilledRobot >i : number >0 : 0 >i < 1 : boolean @@ -178,7 +178,7 @@ for (let [, [primarySkillA, secondarySkillA]] = ["trimmer", ["trimming", "edging for (let [numberB] = robotA, i = 0; i < 1; i++) { >numberB : number ->robotA : [number, string, string] +>robotA : Robot >i : number >0 : 0 >i < 1 : boolean @@ -196,8 +196,8 @@ for (let [numberB] = robotA, i = 0; i < 1; i++) { } for (let [numberB] = getRobot(), i = 0; i < 1; i++) { >numberB : number ->getRobot() : [number, string, string] ->getRobot : () => [number, string, string] +>getRobot() : Robot +>getRobot : () => Robot >i : number >0 : 0 >i < 1 : boolean @@ -236,7 +236,7 @@ for (let [numberB] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { } for (let [nameB] = multiRobotA, i = 0; i < 1; i++) { >nameB : string ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot >i : number >0 : 0 >i < 1 : boolean @@ -254,8 +254,8 @@ for (let [nameB] = multiRobotA, i = 0; i < 1; i++) { } for (let [nameB] = getMultiRobot(), i = 0; i < 1; i++) { >nameB : string ->getMultiRobot() : [string, [string, string]] ->getMultiRobot : () => [string, [string, string]] +>getMultiRobot() : MultiSkilledRobot +>getMultiRobot : () => MultiSkilledRobot >i : number >0 : 0 >i < 1 : boolean @@ -298,7 +298,7 @@ for (let [numberA2, nameA2, skillA2] = robotA, i = 0; i < 1; i++) { >numberA2 : number >nameA2 : string >skillA2 : string ->robotA : [number, string, string] +>robotA : Robot >i : number >0 : 0 >i < 1 : boolean @@ -318,8 +318,8 @@ for (let [numberA2, nameA2, skillA2] = getRobot(), i = 0; i < 1; i++) { >numberA2 : number >nameA2 : string >skillA2 : string ->getRobot() : [number, string, string] ->getRobot : () => [number, string, string] +>getRobot() : Robot +>getRobot : () => Robot >i : number >0 : 0 >i < 1 : boolean @@ -362,7 +362,7 @@ for (let [nameMA, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0; i < 1; >nameMA : string >primarySkillA : string >secondarySkillA : string ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot >i : number >0 : 0 >i < 1 : boolean @@ -382,8 +382,8 @@ for (let [nameMA, [primarySkillA, secondarySkillA]] = getMultiRobot(), i = 0; i >nameMA : string >primarySkillA : string >secondarySkillA : string ->getMultiRobot() : [string, [string, string]] ->getMultiRobot : () => [string, [string, string]] +>getMultiRobot() : MultiSkilledRobot +>getMultiRobot : () => MultiSkilledRobot >i : number >0 : 0 >i < 1 : boolean @@ -427,7 +427,7 @@ for (let [nameMA, [primarySkillA, secondarySkillA]] = ["trimmer", ["trimming", " for (let [numberA3, ...robotAInfo] = robotA, i = 0; i < 1; i++) { >numberA3 : number >robotAInfo : [string, string] ->robotA : [number, string, string] +>robotA : Robot >i : number >0 : 0 >i < 1 : boolean @@ -446,8 +446,8 @@ for (let [numberA3, ...robotAInfo] = robotA, i = 0; i < 1; i++) { for (let [numberA3, ...robotAInfo] = getRobot(), i = 0; i < 1; i++) { >numberA3 : number >robotAInfo : [string, string] ->getRobot() : [number, string, string] ->getRobot : () => [number, string, string] +>getRobot() : Robot +>getRobot : () => Robot >i : number >0 : 0 >i < 1 : boolean @@ -487,7 +487,7 @@ for (let [numberA3, ...robotAInfo] = [2, "trimmer", "trimming"], i = 0; i < 1; i } for (let [...multiRobotAInfo] = multiRobotA, i = 0; i < 1; i++) { >multiRobotAInfo : [string, [string, string]] ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot >i : number >0 : 0 >i < 1 : boolean @@ -505,8 +505,8 @@ for (let [...multiRobotAInfo] = multiRobotA, i = 0; i < 1; i++) { } for (let [...multiRobotAInfo] = getMultiRobot(), i = 0; i < 1; i++) { >multiRobotAInfo : [string, [string, string]] ->getMultiRobot() : [string, [string, string]] ->getMultiRobot : () => [string, [string, string]] +>getMultiRobot() : MultiSkilledRobot +>getMultiRobot : () => MultiSkilledRobot >i : number >0 : 0 >i < 1 : boolean diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPattern2.types b/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPattern2.types index 3f198ebc80f..bfa1757d616 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPattern2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPattern2.types @@ -7,27 +7,27 @@ declare var console: { >msg : any } type Robot = [number, string, string]; ->Robot : [number, string, string] +>Robot : Robot type MultiSkilledRobot = [string, [string, string]]; ->MultiSkilledRobot : [string, [string, string]] +>MultiSkilledRobot : MultiSkilledRobot let robotA: Robot = [1, "mower", "mowing"]; ->robotA : [number, string, string] +>robotA : Robot >[1, "mower", "mowing"] : [number, string, string] >1 : 1 >"mower" : "mower" >"mowing" : "mowing" function getRobot() { ->getRobot : () => [number, string, string] +>getRobot : () => Robot return robotA; ->robotA : [number, string, string] +>robotA : Robot } let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot >["mower", ["mowing", ""]] : [string, [string, string]] >"mower" : "mower" >["mowing", ""] : [string, string] @@ -35,7 +35,7 @@ let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >"" : "" let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; ->multiRobotB : [string, [string, string]] +>multiRobotB : MultiSkilledRobot >["trimmer", ["trimming", "edging"]] : [string, [string, string]] >"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] @@ -43,10 +43,10 @@ let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; >"edging" : "edging" function getMultiRobot() { ->getMultiRobot : () => [string, [string, string]] +>getMultiRobot : () => MultiSkilledRobot return multiRobotA; ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot } let nameA: string, primarySkillA: string, secondarySkillA: string; @@ -74,11 +74,11 @@ let i: number; for ([, nameA] = robotA, i = 0; i < 1; i++) { >[, nameA] = robotA, i = 0 : 0 ->[, nameA] = robotA : [number, string, string] +>[, nameA] = robotA : Robot >[, nameA] : [undefined, string] > : undefined >nameA : string ->robotA : [number, string, string] +>robotA : Robot >i = 0 : 0 >i : number >0 : 0 @@ -97,12 +97,12 @@ for ([, nameA] = robotA, i = 0; i < 1; i++) { } for ([, nameA] = getRobot(), i = 0; i < 1; i++) { >[, nameA] = getRobot(), i = 0 : 0 ->[, nameA] = getRobot() : [number, string, string] +>[, nameA] = getRobot() : Robot >[, nameA] : [undefined, string] > : undefined >nameA : string ->getRobot() : [number, string, string] ->getRobot : () => [number, string, string] +>getRobot() : Robot +>getRobot : () => Robot >i = 0 : 0 >i : number >0 : 0 @@ -147,13 +147,13 @@ for ([, nameA] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { } for ([, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0; i < 1; i++) { >[, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0 : 0 ->[, [primarySkillA, secondarySkillA]] = multiRobotA : [string, [string, string]] +>[, [primarySkillA, secondarySkillA]] = multiRobotA : MultiSkilledRobot >[, [primarySkillA, secondarySkillA]] : [undefined, [string, string]] > : undefined >[primarySkillA, secondarySkillA] : [string, string] >primarySkillA : string >secondarySkillA : string ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot >i = 0 : 0 >i : number >0 : 0 @@ -172,14 +172,14 @@ for ([, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0; i < 1; i++) { } for ([, [primarySkillA, secondarySkillA]] = getMultiRobot(), i = 0; i < 1; i++) { >[, [primarySkillA, secondarySkillA]] = getMultiRobot(), i = 0 : 0 ->[, [primarySkillA, secondarySkillA]] = getMultiRobot() : [string, [string, string]] +>[, [primarySkillA, secondarySkillA]] = getMultiRobot() : MultiSkilledRobot >[, [primarySkillA, secondarySkillA]] : [undefined, [string, string]] > : undefined >[primarySkillA, secondarySkillA] : [string, string] >primarySkillA : string >secondarySkillA : string ->getMultiRobot() : [string, [string, string]] ->getMultiRobot : () => [string, [string, string]] +>getMultiRobot() : MultiSkilledRobot +>getMultiRobot : () => MultiSkilledRobot >i = 0 : 0 >i : number >0 : 0 @@ -228,10 +228,10 @@ for ([, [primarySkillA, secondarySkillA]] = ["trimmer", ["trimming", "edging"]], for ([numberB] = robotA, i = 0; i < 1; i++) { >[numberB] = robotA, i = 0 : 0 ->[numberB] = robotA : [number, string, string] +>[numberB] = robotA : Robot >[numberB] : [number] >numberB : number ->robotA : [number, string, string] +>robotA : Robot >i = 0 : 0 >i : number >0 : 0 @@ -250,11 +250,11 @@ for ([numberB] = robotA, i = 0; i < 1; i++) { } for ([numberB] = getRobot(), i = 0; i < 1; i++) { >[numberB] = getRobot(), i = 0 : 0 ->[numberB] = getRobot() : [number, string, string] +>[numberB] = getRobot() : Robot >[numberB] : [number] >numberB : number ->getRobot() : [number, string, string] ->getRobot : () => [number, string, string] +>getRobot() : Robot +>getRobot : () => Robot >i = 0 : 0 >i : number >0 : 0 @@ -298,10 +298,10 @@ for ([numberB] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { } for ([nameB] = multiRobotA, i = 0; i < 1; i++) { >[nameB] = multiRobotA, i = 0 : 0 ->[nameB] = multiRobotA : [string, [string, string]] +>[nameB] = multiRobotA : MultiSkilledRobot >[nameB] : [string] >nameB : string ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot >i = 0 : 0 >i : number >0 : 0 @@ -320,11 +320,11 @@ for ([nameB] = multiRobotA, i = 0; i < 1; i++) { } for ([nameB] = getMultiRobot(), i = 0; i < 1; i++) { >[nameB] = getMultiRobot(), i = 0 : 0 ->[nameB] = getMultiRobot() : [string, [string, string]] +>[nameB] = getMultiRobot() : MultiSkilledRobot >[nameB] : [string] >nameB : string ->getMultiRobot() : [string, [string, string]] ->getMultiRobot : () => [string, [string, string]] +>getMultiRobot() : MultiSkilledRobot +>getMultiRobot : () => MultiSkilledRobot >i = 0 : 0 >i : number >0 : 0 @@ -370,12 +370,12 @@ for ([nameB] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) { for ([numberA2, nameA2, skillA2] = robotA, i = 0; i < 1; i++) { >[numberA2, nameA2, skillA2] = robotA, i = 0 : 0 ->[numberA2, nameA2, skillA2] = robotA : [number, string, string] +>[numberA2, nameA2, skillA2] = robotA : Robot >[numberA2, nameA2, skillA2] : [number, string, string] >numberA2 : number >nameA2 : string >skillA2 : string ->robotA : [number, string, string] +>robotA : Robot >i = 0 : 0 >i : number >0 : 0 @@ -394,13 +394,13 @@ for ([numberA2, nameA2, skillA2] = robotA, i = 0; i < 1; i++) { } for ([numberA2, nameA2, skillA2] = getRobot(), i = 0; i < 1; i++) { >[numberA2, nameA2, skillA2] = getRobot(), i = 0 : 0 ->[numberA2, nameA2, skillA2] = getRobot() : [number, string, string] +>[numberA2, nameA2, skillA2] = getRobot() : Robot >[numberA2, nameA2, skillA2] : [number, string, string] >numberA2 : number >nameA2 : string >skillA2 : string ->getRobot() : [number, string, string] ->getRobot : () => [number, string, string] +>getRobot() : Robot +>getRobot : () => Robot >i = 0 : 0 >i : number >0 : 0 @@ -446,13 +446,13 @@ for ([numberA2, nameA2, skillA2] = [2, "trimmer", "trimming"], i = 0; i < 1; i++ } for ([nameMA, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0; i < 1; i++) { >[nameMA, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0 : 0 ->[nameMA, [primarySkillA, secondarySkillA]] = multiRobotA : [string, [string, string]] +>[nameMA, [primarySkillA, secondarySkillA]] = multiRobotA : MultiSkilledRobot >[nameMA, [primarySkillA, secondarySkillA]] : [string, [string, string]] >nameMA : string >[primarySkillA, secondarySkillA] : [string, string] >primarySkillA : string >secondarySkillA : string ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot >i = 0 : 0 >i : number >0 : 0 @@ -471,14 +471,14 @@ for ([nameMA, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0; i < 1; i++ } for ([nameMA, [primarySkillA, secondarySkillA]] = getMultiRobot(), i = 0; i < 1; i++) { >[nameMA, [primarySkillA, secondarySkillA]] = getMultiRobot(), i = 0 : 0 ->[nameMA, [primarySkillA, secondarySkillA]] = getMultiRobot() : [string, [string, string]] +>[nameMA, [primarySkillA, secondarySkillA]] = getMultiRobot() : MultiSkilledRobot >[nameMA, [primarySkillA, secondarySkillA]] : [string, [string, string]] >nameMA : string >[primarySkillA, secondarySkillA] : [string, string] >primarySkillA : string >secondarySkillA : string ->getMultiRobot() : [string, [string, string]] ->getMultiRobot : () => [string, [string, string]] +>getMultiRobot() : MultiSkilledRobot +>getMultiRobot : () => MultiSkilledRobot >i = 0 : 0 >i : number >0 : 0 @@ -527,12 +527,12 @@ for ([nameMA, [primarySkillA, secondarySkillA]] = ["trimmer", ["trimming", "edgi for ([numberA3, ...robotAInfo] = robotA, i = 0; i < 1; i++) { >[numberA3, ...robotAInfo] = robotA, i = 0 : 0 ->[numberA3, ...robotAInfo] = robotA : [number, string, string] +>[numberA3, ...robotAInfo] = robotA : Robot >[numberA3, ...robotAInfo] : [number, ...(string | number)[]] >numberA3 : number >...robotAInfo : string | number >robotAInfo : (string | number)[] ->robotA : [number, string, string] +>robotA : Robot >i = 0 : 0 >i : number >0 : 0 @@ -551,13 +551,13 @@ for ([numberA3, ...robotAInfo] = robotA, i = 0; i < 1; i++) { } for ([numberA3, ...robotAInfo] = getRobot(), i = 0; i < 1; i++) { >[numberA3, ...robotAInfo] = getRobot(), i = 0 : 0 ->[numberA3, ...robotAInfo] = getRobot() : [number, string, string] +>[numberA3, ...robotAInfo] = getRobot() : Robot >[numberA3, ...robotAInfo] : [number, ...(string | number)[]] >numberA3 : number >...robotAInfo : string | number >robotAInfo : (string | number)[] ->getRobot() : [number, string, string] ->getRobot : () => [number, string, string] +>getRobot() : Robot +>getRobot : () => Robot >i = 0 : 0 >i : number >0 : 0 @@ -576,12 +576,12 @@ for ([numberA3, ...robotAInfo] = getRobot(), i = 0; i < 1; i++) { } for ([numberA3, ...robotAInfo] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { >[numberA3, ...robotAInfo] = [2, "trimmer", "trimming"], i = 0 : 0 ->[numberA3, ...robotAInfo] = [2, "trimmer", "trimming"] : [number, string, string] +>[numberA3, ...robotAInfo] = [2, "trimmer", "trimming"] : Robot >[numberA3, ...robotAInfo] : [number, ...(string | number)[]] >numberA3 : number >...robotAInfo : string | number >robotAInfo : (string | number)[] ->[2, "trimmer", "trimming"] : [number, string, string] +>[2, "trimmer", "trimming"] : Robot >[2, "trimmer", "trimming"] : [number, string, string] >2 : 2 >"trimmer" : "trimmer" @@ -604,11 +604,11 @@ for ([numberA3, ...robotAInfo] = [2, "trimmer", "trimming"], i = 0; i < 1 } for ([...multiRobotAInfo] = multiRobotA, i = 0; i < 1; i++) { >[...multiRobotAInfo] = multiRobotA, i = 0 : 0 ->[...multiRobotAInfo] = multiRobotA : [string, [string, string]] +>[...multiRobotAInfo] = multiRobotA : MultiSkilledRobot >[...multiRobotAInfo] : (string | [string, string])[] >...multiRobotAInfo : string | [string, string] >multiRobotAInfo : (string | [string, string])[] ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot >i = 0 : 0 >i : number >0 : 0 @@ -627,12 +627,12 @@ for ([...multiRobotAInfo] = multiRobotA, i = 0; i < 1; i++) { } for ([...multiRobotAInfo] = getMultiRobot(), i = 0; i < 1; i++) { >[...multiRobotAInfo] = getMultiRobot(), i = 0 : 0 ->[...multiRobotAInfo] = getMultiRobot() : [string, [string, string]] +>[...multiRobotAInfo] = getMultiRobot() : MultiSkilledRobot >[...multiRobotAInfo] : (string | [string, string])[] >...multiRobotAInfo : string | [string, string] >multiRobotAInfo : (string | [string, string])[] ->getMultiRobot() : [string, [string, string]] ->getMultiRobot : () => [string, [string, string]] +>getMultiRobot() : MultiSkilledRobot +>getMultiRobot : () => MultiSkilledRobot >i = 0 : 0 >i : number >0 : 0 @@ -651,11 +651,11 @@ for ([...multiRobotAInfo] = getMultiRobot(), i = 0; i < 1; i++) { } for ([...multiRobotAInfo] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) { >[...multiRobotAInfo] = ["trimmer", ["trimming", "edging"]], i = 0 : 0 ->[...multiRobotAInfo] = ["trimmer", ["trimming", "edging"]] : [string, [string, string]] +>[...multiRobotAInfo] = ["trimmer", ["trimming", "edging"]] : MultiSkilledRobot >[...multiRobotAInfo] : (string | [string, string])[] >...multiRobotAInfo : string | [string, string] >multiRobotAInfo : (string | [string, string])[] ->["trimmer", ["trimming", "edging"]] : [string, [string, string]] +>["trimmer", ["trimming", "edging"]] : MultiSkilledRobot >["trimmer", ["trimming", "edging"]] : [string, [string, string]] >"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues.types b/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues.types index ee16f28a9d5..2dab0c1cd6b 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues.types @@ -7,27 +7,27 @@ declare var console: { >msg : any } type Robot = [number, string, string]; ->Robot : [number, string, string] +>Robot : Robot type MultiSkilledRobot = [string, string[]]; ->MultiSkilledRobot : [string, string[]] +>MultiSkilledRobot : MultiSkilledRobot let robotA: Robot = [1, "mower", "mowing"]; ->robotA : [number, string, string] +>robotA : Robot >[1, "mower", "mowing"] : [number, string, string] >1 : 1 >"mower" : "mower" >"mowing" : "mowing" function getRobot() { ->getRobot : () => [number, string, string] +>getRobot : () => Robot return robotA; ->robotA : [number, string, string] +>robotA : Robot } let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; ->multiRobotA : [string, string[]] +>multiRobotA : MultiSkilledRobot >["mower", ["mowing", ""]] : [string, string[]] >"mower" : "mower" >["mowing", ""] : string[] @@ -35,7 +35,7 @@ let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >"" : "" let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; ->multiRobotB : [string, string[]] +>multiRobotB : MultiSkilledRobot >["trimmer", ["trimming", "edging"]] : [string, string[]] >"trimmer" : "trimmer" >["trimming", "edging"] : string[] @@ -43,17 +43,17 @@ let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; >"edging" : "edging" function getMultiRobot() { ->getMultiRobot : () => [string, string[]] +>getMultiRobot : () => MultiSkilledRobot return multiRobotA; ->multiRobotA : [string, string[]] +>multiRobotA : MultiSkilledRobot } for (let [, nameA ="name"] = robotA, i = 0; i < 1; i++) { > : undefined >nameA : string >"name" : "name" ->robotA : [number, string, string] +>robotA : Robot >i : number >0 : 0 >i < 1 : boolean @@ -73,8 +73,8 @@ for (let [, nameA = "name"] = getRobot(), i = 0; i < 1; i++) { > : undefined >nameA : string >"name" : "name" ->getRobot() : [number, string, string] ->getRobot : () => [number, string, string] +>getRobot() : Robot +>getRobot : () => Robot >i : number >0 : 0 >i < 1 : boolean @@ -128,7 +128,7 @@ for (let [, [ >["none", "none"] : [string, string] >"none" : "none" >"none" : "none" ->multiRobotA : [string, string[]] +>multiRobotA : MultiSkilledRobot >i : number >0 : 0 >i < 1 : boolean @@ -159,8 +159,8 @@ for (let [, [ >["none", "none"] : [string, string] >"none" : "none" >"none" : "none" ->getMultiRobot() : [string, string[]] ->getMultiRobot : () => [string, string[]] +>getMultiRobot() : MultiSkilledRobot +>getMultiRobot : () => MultiSkilledRobot >i : number >0 : 0 >i < 1 : boolean @@ -216,7 +216,7 @@ for (let [numberB = -1] = robotA, i = 0; i < 1; i++) { >numberB : number >-1 : -1 >1 : 1 ->robotA : [number, string, string] +>robotA : Robot >i : number >0 : 0 >i < 1 : boolean @@ -236,8 +236,8 @@ for (let [numberB = -1] = getRobot(), i = 0; i < 1; i++) { >numberB : number >-1 : -1 >1 : 1 ->getRobot() : [number, string, string] ->getRobot : () => [number, string, string] +>getRobot() : Robot +>getRobot : () => Robot >i : number >0 : 0 >i < 1 : boolean @@ -279,7 +279,7 @@ for (let [numberB = -1] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { for (let [nameB = "name"] = multiRobotA, i = 0; i < 1; i++) { >nameB : string >"name" : "name" ->multiRobotA : [string, string[]] +>multiRobotA : MultiSkilledRobot >i : number >0 : 0 >i < 1 : boolean @@ -298,8 +298,8 @@ for (let [nameB = "name"] = multiRobotA, i = 0; i < 1; i++) { for (let [nameB = "name"] = getMultiRobot(), i = 0; i < 1; i++) { >nameB : string >"name" : "name" ->getMultiRobot() : [string, string[]] ->getMultiRobot : () => [string, string[]] +>getMultiRobot() : MultiSkilledRobot +>getMultiRobot : () => MultiSkilledRobot >i : number >0 : 0 >i < 1 : boolean @@ -347,7 +347,7 @@ for (let [numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = robotA, i = 0; i >"name" : "name" >skillA2 : string >"skill" : "skill" ->robotA : [number, string, string] +>robotA : Robot >i : number >0 : 0 >i < 1 : boolean @@ -371,8 +371,8 @@ for (let [numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = getRobot(), i = 0 >"name" : "name" >skillA2 : string >"skill" : "skill" ->getRobot() : [number, string, string] ->getRobot : () => [number, string, string] +>getRobot() : Robot +>getRobot : () => Robot >i : number >0 : 0 >i < 1 : boolean @@ -435,7 +435,7 @@ for (let >"none" : "none" ] = multiRobotA, i = 0; i < 1; i++) { ->multiRobotA : [string, string[]] +>multiRobotA : MultiSkilledRobot >i : number >0 : 0 >i < 1 : boolean @@ -470,8 +470,8 @@ for (let [nameMA = "noName", >"none" : "none" ] = getMultiRobot(), i = 0; i < 1; i++) { ->getMultiRobot() : [string, string[]] ->getMultiRobot : () => [string, string[]] +>getMultiRobot() : MultiSkilledRobot +>getMultiRobot : () => MultiSkilledRobot >i : number >0 : 0 >i < 1 : boolean @@ -532,7 +532,7 @@ for (let [numberA3 = -1, ...robotAInfo] = robotA, i = 0; i < 1; i++) { >-1 : -1 >1 : 1 >robotAInfo : [string, string] ->robotA : [number, string, string] +>robotA : Robot >i : number >0 : 0 >i < 1 : boolean @@ -553,8 +553,8 @@ for (let [numberA3 = -1, ...robotAInfo] = getRobot(), i = 0; i < 1; i++) { >-1 : -1 >1 : 1 >robotAInfo : [string, string] ->getRobot() : [number, string, string] ->getRobot : () => [number, string, string] +>getRobot() : Robot +>getRobot : () => Robot >i : number >0 : 0 >i < 1 : boolean diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues2.types b/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues2.types index 9175ee68dca..aa06efe3965 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues2.types @@ -7,27 +7,27 @@ declare var console: { >msg : any } type Robot = [number, string, string]; ->Robot : [number, string, string] +>Robot : Robot type MultiSkilledRobot = [string, [string, string]]; ->MultiSkilledRobot : [string, [string, string]] +>MultiSkilledRobot : MultiSkilledRobot let robotA: Robot = [1, "mower", "mowing"]; ->robotA : [number, string, string] +>robotA : Robot >[1, "mower", "mowing"] : [number, string, string] >1 : 1 >"mower" : "mower" >"mowing" : "mowing" function getRobot() { ->getRobot : () => [number, string, string] +>getRobot : () => Robot return robotA; ->robotA : [number, string, string] +>robotA : Robot } let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot >["mower", ["mowing", ""]] : [string, [string, string]] >"mower" : "mower" >["mowing", ""] : [string, string] @@ -35,7 +35,7 @@ let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >"" : "" let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; ->multiRobotB : [string, [string, string]] +>multiRobotB : MultiSkilledRobot >["trimmer", ["trimming", "edging"]] : [string, [string, string]] >"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] @@ -43,10 +43,10 @@ let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; >"edging" : "edging" function getMultiRobot() { ->getMultiRobot : () => [string, [string, string]] +>getMultiRobot : () => MultiSkilledRobot return multiRobotA; ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot } let nameA: string, primarySkillA: string, secondarySkillA: string; @@ -74,13 +74,13 @@ let i: number; for ([, nameA = "name"] = robotA, i = 0; i < 1; i++) { >[, nameA = "name"] = robotA, i = 0 : 0 ->[, nameA = "name"] = robotA : [number, string, string] +>[, nameA = "name"] = robotA : Robot >[, nameA = "name"] : [undefined, string] > : undefined >nameA = "name" : "name" >nameA : string >"name" : "name" ->robotA : [number, string, string] +>robotA : Robot >i = 0 : 0 >i : number >0 : 0 @@ -99,14 +99,14 @@ for ([, nameA = "name"] = robotA, i = 0; i < 1; i++) { } for ([, nameA = "name"] = getRobot(), i = 0; i < 1; i++) { >[, nameA = "name"] = getRobot(), i = 0 : 0 ->[, nameA = "name"] = getRobot() : [number, string, string] +>[, nameA = "name"] = getRobot() : Robot >[, nameA = "name"] : [undefined, string] > : undefined >nameA = "name" : "name" >nameA : string >"name" : "name" ->getRobot() : [number, string, string] ->getRobot : () => [number, string, string] +>getRobot() : Robot +>getRobot : () => Robot >i = 0 : 0 >i : number >0 : 0 @@ -153,7 +153,7 @@ for ([, nameA = "name"] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { } for ([, [ >[, [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"]] = multiRobotA, i = 0 : 0 ->[, [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"]] = multiRobotA : [string, [string, string]] +>[, [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"]] = multiRobotA : MultiSkilledRobot >[, [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"]] : [undefined, [string, string]] > : undefined >[ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"] : [string, string] @@ -173,7 +173,7 @@ for ([, [ >["none", "none"] : [string, string] >"none" : "none" >"none" : "none" ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot >i = 0 : 0 >i : number >0 : 0 @@ -192,7 +192,7 @@ for ([, [ } for ([, [ >[, [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"]] = getMultiRobot(), i = 0 : 0 ->[, [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"]] = getMultiRobot() : [string, [string, string]] +>[, [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"]] = getMultiRobot() : MultiSkilledRobot >[, [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"]] : [undefined, [string, string]] > : undefined >[ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"] : [string, string] @@ -212,8 +212,8 @@ for ([, [ >["none", "none"] : [string, string] >"none" : "none" >"none" : "none" ->getMultiRobot() : [string, [string, string]] ->getMultiRobot : () => [string, [string, string]] +>getMultiRobot() : MultiSkilledRobot +>getMultiRobot : () => MultiSkilledRobot >i = 0 : 0 >i : number >0 : 0 @@ -276,13 +276,13 @@ for ([, [ for ([numberB = -1] = robotA, i = 0; i < 1; i++) { >[numberB = -1] = robotA, i = 0 : 0 ->[numberB = -1] = robotA : [number, string, string] +>[numberB = -1] = robotA : Robot >[numberB = -1] : [number] >numberB = -1 : -1 >numberB : number >-1 : -1 >1 : 1 ->robotA : [number, string, string] +>robotA : Robot >i = 0 : 0 >i : number >0 : 0 @@ -301,14 +301,14 @@ for ([numberB = -1] = robotA, i = 0; i < 1; i++) { } for ([numberB = -1] = getRobot(), i = 0; i < 1; i++) { >[numberB = -1] = getRobot(), i = 0 : 0 ->[numberB = -1] = getRobot() : [number, string, string] +>[numberB = -1] = getRobot() : Robot >[numberB = -1] : [number] >numberB = -1 : -1 >numberB : number >-1 : -1 >1 : 1 ->getRobot() : [number, string, string] ->getRobot : () => [number, string, string] +>getRobot() : Robot +>getRobot : () => Robot >i = 0 : 0 >i : number >0 : 0 @@ -355,12 +355,12 @@ for ([numberB = -1] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { } for ([nameB = "name"] = multiRobotA, i = 0; i < 1; i++) { >[nameB = "name"] = multiRobotA, i = 0 : 0 ->[nameB = "name"] = multiRobotA : [string, [string, string]] +>[nameB = "name"] = multiRobotA : MultiSkilledRobot >[nameB = "name"] : [string] >nameB = "name" : "name" >nameB : string >"name" : "name" ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot >i = 0 : 0 >i : number >0 : 0 @@ -379,13 +379,13 @@ for ([nameB = "name"] = multiRobotA, i = 0; i < 1; i++) { } for ([nameB = "name"] = getMultiRobot(), i = 0; i < 1; i++) { >[nameB = "name"] = getMultiRobot(), i = 0 : 0 ->[nameB = "name"] = getMultiRobot() : [string, [string, string]] +>[nameB = "name"] = getMultiRobot() : MultiSkilledRobot >[nameB = "name"] : [string] >nameB = "name" : "name" >nameB : string >"name" : "name" ->getMultiRobot() : [string, [string, string]] ->getMultiRobot : () => [string, [string, string]] +>getMultiRobot() : MultiSkilledRobot +>getMultiRobot : () => MultiSkilledRobot >i = 0 : 0 >i : number >0 : 0 @@ -433,7 +433,7 @@ for ([nameB = "name"] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) for ([numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = robotA, i = 0; i < 1; i++) { >[numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = robotA, i = 0 : 0 ->[numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = robotA : [number, string, string] +>[numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = robotA : Robot >[numberA2 = -1, nameA2 = "name", skillA2 = "skill"] : [number, string, string] >numberA2 = -1 : -1 >numberA2 : number @@ -445,7 +445,7 @@ for ([numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = robotA, i = 0; i < 1; >skillA2 = "skill" : "skill" >skillA2 : string >"skill" : "skill" ->robotA : [number, string, string] +>robotA : Robot >i = 0 : 0 >i : number >0 : 0 @@ -464,7 +464,7 @@ for ([numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = robotA, i = 0; i < 1; } for ([numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = getRobot(), i = 0; i < 1; i++) { >[numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = getRobot(), i = 0 : 0 ->[numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = getRobot() : [number, string, string] +>[numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = getRobot() : Robot >[numberA2 = -1, nameA2 = "name", skillA2 = "skill"] : [number, string, string] >numberA2 = -1 : -1 >numberA2 : number @@ -476,8 +476,8 @@ for ([numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = getRobot(), i = 0; i >skillA2 = "skill" : "skill" >skillA2 : string >"skill" : "skill" ->getRobot() : [number, string, string] ->getRobot : () => [number, string, string] +>getRobot() : Robot +>getRobot : () => Robot >i = 0 : 0 >i : number >0 : 0 @@ -548,7 +548,7 @@ for (let >"none" : "none" ] = multiRobotA, i = 0; i < 1; i++) { ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot >i : number >0 : 0 >i < 1 : boolean @@ -566,7 +566,7 @@ for (let } for ([nameMA = "noName", >[nameMA = "noName", [ primarySkillA = "primary", secondarySkillA = "secondary" ] = ["none", "none"]] = getMultiRobot(), i = 0 : 0 ->[nameMA = "noName", [ primarySkillA = "primary", secondarySkillA = "secondary" ] = ["none", "none"]] = getMultiRobot() : [string, [string, string]] +>[nameMA = "noName", [ primarySkillA = "primary", secondarySkillA = "secondary" ] = ["none", "none"]] = getMultiRobot() : MultiSkilledRobot >[nameMA = "noName", [ primarySkillA = "primary", secondarySkillA = "secondary" ] = ["none", "none"]] : [string, [string, string]] >nameMA = "noName" : "noName" >nameMA : string @@ -592,8 +592,8 @@ for ([nameMA = "noName", >"none" : "none" ] = getMultiRobot(), i = 0; i < 1; i++) { ->getMultiRobot() : [string, [string, string]] ->getMultiRobot : () => [string, [string, string]] +>getMultiRobot() : MultiSkilledRobot +>getMultiRobot : () => MultiSkilledRobot >i = 0 : 0 >i : number >0 : 0 @@ -662,7 +662,7 @@ for ([nameMA = "noName", for ([numberA3 = -1, ...robotAInfo] = robotA, i = 0; i < 1; i++) { >[numberA3 = -1, ...robotAInfo] = robotA, i = 0 : 0 ->[numberA3 = -1, ...robotAInfo] = robotA : [number, string, string] +>[numberA3 = -1, ...robotAInfo] = robotA : Robot >[numberA3 = -1, ...robotAInfo] : [number, ...(string | number)[]] >numberA3 = -1 : -1 >numberA3 : number @@ -670,7 +670,7 @@ for ([numberA3 = -1, ...robotAInfo] = robotA, i = 0; i < 1; i++) { >1 : 1 >...robotAInfo : string | number >robotAInfo : (string | number)[] ->robotA : [number, string, string] +>robotA : Robot >i = 0 : 0 >i : number >0 : 0 @@ -689,7 +689,7 @@ for ([numberA3 = -1, ...robotAInfo] = robotA, i = 0; i < 1; i++) { } for ([numberA3 = -1, ...robotAInfo] = getRobot(), i = 0; i < 1; i++) { >[numberA3 = -1, ...robotAInfo] = getRobot(), i = 0 : 0 ->[numberA3 = -1, ...robotAInfo] = getRobot() : [number, string, string] +>[numberA3 = -1, ...robotAInfo] = getRobot() : Robot >[numberA3 = -1, ...robotAInfo] : [number, ...(string | number)[]] >numberA3 = -1 : -1 >numberA3 : number @@ -697,8 +697,8 @@ for ([numberA3 = -1, ...robotAInfo] = getRobot(), i = 0; i < 1; i++) { >1 : 1 >...robotAInfo : string | number >robotAInfo : (string | number)[] ->getRobot() : [number, string, string] ->getRobot : () => [number, string, string] +>getRobot() : Robot +>getRobot : () => Robot >i = 0 : 0 >i : number >0 : 0 @@ -717,7 +717,7 @@ for ([numberA3 = -1, ...robotAInfo] = getRobot(), i = 0; i < 1; i++) { } for ([numberA3 = -1, ...robotAInfo] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { >[numberA3 = -1, ...robotAInfo] = [2, "trimmer", "trimming"], i = 0 : 0 ->[numberA3 = -1, ...robotAInfo] = [2, "trimmer", "trimming"] : [number, string, string] +>[numberA3 = -1, ...robotAInfo] = [2, "trimmer", "trimming"] : Robot >[numberA3 = -1, ...robotAInfo] : [number, ...(string | number)[]] >numberA3 = -1 : -1 >numberA3 : number @@ -725,7 +725,7 @@ for ([numberA3 = -1, ...robotAInfo] = [2, "trimmer", "trimming"], i = 0; >1 : 1 >...robotAInfo : string | number >robotAInfo : (string | number)[] ->[2, "trimmer", "trimming"] : [number, string, string] +>[2, "trimmer", "trimming"] : Robot >[2, "trimmer", "trimming"] : [number, string, string] >2 : 2 >"trimmer" : "trimmer" diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPattern.types b/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPattern.types index 57fa951a2c7..f38bc8330ef 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPattern.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPattern.types @@ -7,40 +7,40 @@ declare var console: { >msg : any } type Robot = [number, string, string]; ->Robot : [number, string, string] +>Robot : Robot type MultiSkilledRobot = [string, [string, string]]; ->MultiSkilledRobot : [string, [string, string]] +>MultiSkilledRobot : MultiSkilledRobot let robotA: Robot = [1, "mower", "mowing"]; ->robotA : [number, string, string] +>robotA : Robot >[1, "mower", "mowing"] : [number, string, string] >1 : 1 >"mower" : "mower" >"mowing" : "mowing" let robotB: Robot = [2, "trimmer", "trimming"]; ->robotB : [number, string, string] +>robotB : Robot >[2, "trimmer", "trimming"] : [number, string, string] >2 : 2 >"trimmer" : "trimmer" >"trimming" : "trimming" let robots = [robotA, robotB]; ->robots : [number, string, string][] ->[robotA, robotB] : [number, string, string][] ->robotA : [number, string, string] ->robotB : [number, string, string] +>robots : Robot[] +>[robotA, robotB] : Robot[] +>robotA : Robot +>robotB : Robot function getRobots() { ->getRobots : () => [number, string, string][] +>getRobots : () => Robot[] return robots; ->robots : [number, string, string][] +>robots : Robot[] } let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot >["mower", ["mowing", ""]] : [string, [string, string]] >"mower" : "mower" >["mowing", ""] : [string, string] @@ -48,7 +48,7 @@ let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >"" : "" let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; ->multiRobotB : [string, [string, string]] +>multiRobotB : MultiSkilledRobot >["trimmer", ["trimming", "edging"]] : [string, [string, string]] >"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] @@ -56,22 +56,22 @@ let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; >"edging" : "edging" let multiRobots = [multiRobotA, multiRobotB]; ->multiRobots : [string, [string, string]][] ->[multiRobotA, multiRobotB] : [string, [string, string]][] ->multiRobotA : [string, [string, string]] ->multiRobotB : [string, [string, string]] +>multiRobots : MultiSkilledRobot[] +>[multiRobotA, multiRobotB] : MultiSkilledRobot[] +>multiRobotA : MultiSkilledRobot +>multiRobotB : MultiSkilledRobot function getMultiRobots() { ->getMultiRobots : () => [string, [string, string]][] +>getMultiRobots : () => MultiSkilledRobot[] return multiRobots; ->multiRobots : [string, [string, string]][] +>multiRobots : MultiSkilledRobot[] } for (let [, nameA] of robots) { > : undefined >nameA : string ->robots : [number, string, string][] +>robots : Robot[] console.log(nameA); >console.log(nameA) : void @@ -83,8 +83,8 @@ for (let [, nameA] of robots) { for (let [, nameA] of getRobots()) { > : undefined >nameA : string ->getRobots() : [number, string, string][] ->getRobots : () => [number, string, string][] +>getRobots() : Robot[] +>getRobots : () => Robot[] console.log(nameA); >console.log(nameA) : void @@ -96,9 +96,9 @@ for (let [, nameA] of getRobots()) { for (let [, nameA] of [robotA, robotB]) { > : undefined >nameA : string ->[robotA, robotB] : [number, string, string][] ->robotA : [number, string, string] ->robotB : [number, string, string] +>[robotA, robotB] : Robot[] +>robotA : Robot +>robotB : Robot console.log(nameA); >console.log(nameA) : void @@ -111,7 +111,7 @@ for (let [, [primarySkillA, secondarySkillA]] of multiRobots) { > : undefined >primarySkillA : string >secondarySkillA : string ->multiRobots : [string, [string, string]][] +>multiRobots : MultiSkilledRobot[] console.log(primarySkillA); >console.log(primarySkillA) : void @@ -124,8 +124,8 @@ for (let [, [primarySkillA, secondarySkillA]] of getMultiRobots()) { > : undefined >primarySkillA : string >secondarySkillA : string ->getMultiRobots() : [string, [string, string]][] ->getMultiRobots : () => [string, [string, string]][] +>getMultiRobots() : MultiSkilledRobot[] +>getMultiRobots : () => MultiSkilledRobot[] console.log(primarySkillA); >console.log(primarySkillA) : void @@ -138,9 +138,9 @@ for (let [, [primarySkillA, secondarySkillA]] of [multiRobotA, multiRobotB]) { > : undefined >primarySkillA : string >secondarySkillA : string ->[multiRobotA, multiRobotB] : [string, [string, string]][] ->multiRobotA : [string, [string, string]] ->multiRobotB : [string, [string, string]] +>[multiRobotA, multiRobotB] : MultiSkilledRobot[] +>multiRobotA : MultiSkilledRobot +>multiRobotB : MultiSkilledRobot console.log(primarySkillA); >console.log(primarySkillA) : void @@ -152,7 +152,7 @@ for (let [, [primarySkillA, secondarySkillA]] of [multiRobotA, multiRobotB]) { for (let [numberB] of robots) { >numberB : number ->robots : [number, string, string][] +>robots : Robot[] console.log(numberB); >console.log(numberB) : void @@ -163,8 +163,8 @@ for (let [numberB] of robots) { } for (let [numberB] of getRobots()) { >numberB : number ->getRobots() : [number, string, string][] ->getRobots : () => [number, string, string][] +>getRobots() : Robot[] +>getRobots : () => Robot[] console.log(numberB); >console.log(numberB) : void @@ -175,9 +175,9 @@ for (let [numberB] of getRobots()) { } for (let [numberB] of [robotA, robotB]) { >numberB : number ->[robotA, robotB] : [number, string, string][] ->robotA : [number, string, string] ->robotB : [number, string, string] +>[robotA, robotB] : Robot[] +>robotA : Robot +>robotB : Robot console.log(numberB); >console.log(numberB) : void @@ -188,7 +188,7 @@ for (let [numberB] of [robotA, robotB]) { } for (let [nameB] of multiRobots) { >nameB : string ->multiRobots : [string, [string, string]][] +>multiRobots : MultiSkilledRobot[] console.log(nameB); >console.log(nameB) : void @@ -199,8 +199,8 @@ for (let [nameB] of multiRobots) { } for (let [nameB] of getMultiRobots()) { >nameB : string ->getMultiRobots() : [string, [string, string]][] ->getMultiRobots : () => [string, [string, string]][] +>getMultiRobots() : MultiSkilledRobot[] +>getMultiRobots : () => MultiSkilledRobot[] console.log(nameB); >console.log(nameB) : void @@ -211,9 +211,9 @@ for (let [nameB] of getMultiRobots()) { } for (let [nameB] of [multiRobotA, multiRobotB]) { >nameB : string ->[multiRobotA, multiRobotB] : [string, [string, string]][] ->multiRobotA : [string, [string, string]] ->multiRobotB : [string, [string, string]] +>[multiRobotA, multiRobotB] : MultiSkilledRobot[] +>multiRobotA : MultiSkilledRobot +>multiRobotB : MultiSkilledRobot console.log(nameB); >console.log(nameB) : void @@ -227,7 +227,7 @@ for (let [numberA2, nameA2, skillA2] of robots) { >numberA2 : number >nameA2 : string >skillA2 : string ->robots : [number, string, string][] +>robots : Robot[] console.log(nameA2); >console.log(nameA2) : void @@ -240,8 +240,8 @@ for (let [numberA2, nameA2, skillA2] of getRobots()) { >numberA2 : number >nameA2 : string >skillA2 : string ->getRobots() : [number, string, string][] ->getRobots : () => [number, string, string][] +>getRobots() : Robot[] +>getRobots : () => Robot[] console.log(nameA2); >console.log(nameA2) : void @@ -254,9 +254,9 @@ for (let [numberA2, nameA2, skillA2] of [robotA, robotB]) { >numberA2 : number >nameA2 : string >skillA2 : string ->[robotA, robotB] : [number, string, string][] ->robotA : [number, string, string] ->robotB : [number, string, string] +>[robotA, robotB] : Robot[] +>robotA : Robot +>robotB : Robot console.log(nameA2); >console.log(nameA2) : void @@ -269,7 +269,7 @@ for (let [nameMA, [primarySkillA, secondarySkillA]] of multiRobots) { >nameMA : string >primarySkillA : string >secondarySkillA : string ->multiRobots : [string, [string, string]][] +>multiRobots : MultiSkilledRobot[] console.log(nameMA); >console.log(nameMA) : void @@ -282,8 +282,8 @@ for (let [nameMA, [primarySkillA, secondarySkillA]] of getMultiRobots()) { >nameMA : string >primarySkillA : string >secondarySkillA : string ->getMultiRobots() : [string, [string, string]][] ->getMultiRobots : () => [string, [string, string]][] +>getMultiRobots() : MultiSkilledRobot[] +>getMultiRobots : () => MultiSkilledRobot[] console.log(nameMA); >console.log(nameMA) : void @@ -296,9 +296,9 @@ for (let [nameMA, [primarySkillA, secondarySkillA]] of [multiRobotA, multiRobotB >nameMA : string >primarySkillA : string >secondarySkillA : string ->[multiRobotA, multiRobotB] : [string, [string, string]][] ->multiRobotA : [string, [string, string]] ->multiRobotB : [string, [string, string]] +>[multiRobotA, multiRobotB] : MultiSkilledRobot[] +>multiRobotA : MultiSkilledRobot +>multiRobotB : MultiSkilledRobot console.log(nameMA); >console.log(nameMA) : void @@ -311,7 +311,7 @@ for (let [nameMA, [primarySkillA, secondarySkillA]] of [multiRobotA, multiRobotB for (let [numberA3, ...robotAInfo] of robots) { >numberA3 : number >robotAInfo : [string, string] ->robots : [number, string, string][] +>robots : Robot[] console.log(numberA3); >console.log(numberA3) : void @@ -323,8 +323,8 @@ for (let [numberA3, ...robotAInfo] of robots) { for (let [numberA3, ...robotAInfo] of getRobots()) { >numberA3 : number >robotAInfo : [string, string] ->getRobots() : [number, string, string][] ->getRobots : () => [number, string, string][] +>getRobots() : Robot[] +>getRobots : () => Robot[] console.log(numberA3); >console.log(numberA3) : void @@ -336,9 +336,9 @@ for (let [numberA3, ...robotAInfo] of getRobots()) { for (let [numberA3, ...robotAInfo] of [robotA, robotB]) { >numberA3 : number >robotAInfo : [string, string] ->[robotA, robotB] : [number, string, string][] ->robotA : [number, string, string] ->robotB : [number, string, string] +>[robotA, robotB] : Robot[] +>robotA : Robot +>robotB : Robot console.log(numberA3); >console.log(numberA3) : void @@ -349,7 +349,7 @@ for (let [numberA3, ...robotAInfo] of [robotA, robotB]) { } for (let [...multiRobotAInfo] of multiRobots) { >multiRobotAInfo : [string, [string, string]] ->multiRobots : [string, [string, string]][] +>multiRobots : MultiSkilledRobot[] console.log(multiRobotAInfo); >console.log(multiRobotAInfo) : void @@ -360,8 +360,8 @@ for (let [...multiRobotAInfo] of multiRobots) { } for (let [...multiRobotAInfo] of getMultiRobots()) { >multiRobotAInfo : [string, [string, string]] ->getMultiRobots() : [string, [string, string]][] ->getMultiRobots : () => [string, [string, string]][] +>getMultiRobots() : MultiSkilledRobot[] +>getMultiRobots : () => MultiSkilledRobot[] console.log(multiRobotAInfo); >console.log(multiRobotAInfo) : void @@ -372,9 +372,9 @@ for (let [...multiRobotAInfo] of getMultiRobots()) { } for (let [...multiRobotAInfo] of [multiRobotA, multiRobotB]) { >multiRobotAInfo : [string, [string, string]] ->[multiRobotA, multiRobotB] : [string, [string, string]][] ->multiRobotA : [string, [string, string]] ->multiRobotB : [string, [string, string]] +>[multiRobotA, multiRobotB] : MultiSkilledRobot[] +>multiRobotA : MultiSkilledRobot +>multiRobotB : MultiSkilledRobot console.log(multiRobotAInfo); >console.log(multiRobotAInfo) : void diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPattern2.types b/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPattern2.types index c6b57fb4f62..92797377d3a 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPattern2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPattern2.types @@ -7,40 +7,40 @@ declare var console: { >msg : any } type Robot = [number, string, string]; ->Robot : [number, string, string] +>Robot : Robot type MultiSkilledRobot = [string, [string, string]]; ->MultiSkilledRobot : [string, [string, string]] +>MultiSkilledRobot : MultiSkilledRobot let robotA: Robot = [1, "mower", "mowing"]; ->robotA : [number, string, string] +>robotA : Robot >[1, "mower", "mowing"] : [number, string, string] >1 : 1 >"mower" : "mower" >"mowing" : "mowing" let robotB: Robot = [2, "trimmer", "trimming"]; ->robotB : [number, string, string] +>robotB : Robot >[2, "trimmer", "trimming"] : [number, string, string] >2 : 2 >"trimmer" : "trimmer" >"trimming" : "trimming" let robots = [robotA, robotB]; ->robots : [number, string, string][] ->[robotA, robotB] : [number, string, string][] ->robotA : [number, string, string] ->robotB : [number, string, string] +>robots : Robot[] +>[robotA, robotB] : Robot[] +>robotA : Robot +>robotB : Robot function getRobots() { ->getRobots : () => [number, string, string][] +>getRobots : () => Robot[] return robots; ->robots : [number, string, string][] +>robots : Robot[] } let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot >["mower", ["mowing", ""]] : [string, [string, string]] >"mower" : "mower" >["mowing", ""] : [string, string] @@ -48,7 +48,7 @@ let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >"" : "" let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; ->multiRobotB : [string, [string, string]] +>multiRobotB : MultiSkilledRobot >["trimmer", ["trimming", "edging"]] : [string, [string, string]] >"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] @@ -56,16 +56,16 @@ let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; >"edging" : "edging" let multiRobots = [multiRobotA, multiRobotB]; ->multiRobots : [string, [string, string]][] ->[multiRobotA, multiRobotB] : [string, [string, string]][] ->multiRobotA : [string, [string, string]] ->multiRobotB : [string, [string, string]] +>multiRobots : MultiSkilledRobot[] +>[multiRobotA, multiRobotB] : MultiSkilledRobot[] +>multiRobotA : MultiSkilledRobot +>multiRobotB : MultiSkilledRobot function getMultiRobots() { ->getMultiRobots : () => [string, [string, string]][] +>getMultiRobots : () => MultiSkilledRobot[] return multiRobots; ->multiRobots : [string, [string, string]][] +>multiRobots : MultiSkilledRobot[] } let nameA: string, primarySkillA: string, secondarySkillA: string; @@ -92,7 +92,7 @@ for ([, nameA] of robots) { >[, nameA] : [undefined, string] > : undefined >nameA : string ->robots : [number, string, string][] +>robots : Robot[] console.log(nameA); >console.log(nameA) : void @@ -105,8 +105,8 @@ for ([, nameA] of getRobots()) { >[, nameA] : [undefined, string] > : undefined >nameA : string ->getRobots() : [number, string, string][] ->getRobots : () => [number, string, string][] +>getRobots() : Robot[] +>getRobots : () => Robot[] console.log(nameA); >console.log(nameA) : void @@ -119,9 +119,9 @@ for ([, nameA] of [robotA, robotB]) { >[, nameA] : [undefined, string] > : undefined >nameA : string ->[robotA, robotB] : [number, string, string][] ->robotA : [number, string, string] ->robotB : [number, string, string] +>[robotA, robotB] : Robot[] +>robotA : Robot +>robotB : Robot console.log(nameA); >console.log(nameA) : void @@ -136,7 +136,7 @@ for ([, [primarySkillA, secondarySkillA]] of multiRobots) { >[primarySkillA, secondarySkillA] : [string, string] >primarySkillA : string >secondarySkillA : string ->multiRobots : [string, [string, string]][] +>multiRobots : MultiSkilledRobot[] console.log(primarySkillA); >console.log(primarySkillA) : void @@ -151,8 +151,8 @@ for ([, [primarySkillA, secondarySkillA]] of getMultiRobots()) { >[primarySkillA, secondarySkillA] : [string, string] >primarySkillA : string >secondarySkillA : string ->getMultiRobots() : [string, [string, string]][] ->getMultiRobots : () => [string, [string, string]][] +>getMultiRobots() : MultiSkilledRobot[] +>getMultiRobots : () => MultiSkilledRobot[] console.log(primarySkillA); >console.log(primarySkillA) : void @@ -167,9 +167,9 @@ for ([, [primarySkillA, secondarySkillA]] of [multiRobotA, multiRobotB]) { >[primarySkillA, secondarySkillA] : [string, string] >primarySkillA : string >secondarySkillA : string ->[multiRobotA, multiRobotB] : [string, [string, string]][] ->multiRobotA : [string, [string, string]] ->multiRobotB : [string, [string, string]] +>[multiRobotA, multiRobotB] : MultiSkilledRobot[] +>multiRobotA : MultiSkilledRobot +>multiRobotB : MultiSkilledRobot console.log(primarySkillA); >console.log(primarySkillA) : void @@ -182,7 +182,7 @@ for ([, [primarySkillA, secondarySkillA]] of [multiRobotA, multiRobotB]) { for ([numberB] of robots) { >[numberB] : [number] >numberB : number ->robots : [number, string, string][] +>robots : Robot[] console.log(numberB); >console.log(numberB) : void @@ -194,8 +194,8 @@ for ([numberB] of robots) { for ([numberB] of getRobots()) { >[numberB] : [number] >numberB : number ->getRobots() : [number, string, string][] ->getRobots : () => [number, string, string][] +>getRobots() : Robot[] +>getRobots : () => Robot[] console.log(numberB); >console.log(numberB) : void @@ -207,9 +207,9 @@ for ([numberB] of getRobots()) { for ([numberB] of [robotA, robotB]) { >[numberB] : [number] >numberB : number ->[robotA, robotB] : [number, string, string][] ->robotA : [number, string, string] ->robotB : [number, string, string] +>[robotA, robotB] : Robot[] +>robotA : Robot +>robotB : Robot console.log(numberB); >console.log(numberB) : void @@ -221,7 +221,7 @@ for ([numberB] of [robotA, robotB]) { for ([nameB] of multiRobots) { >[nameB] : [string] >nameB : string ->multiRobots : [string, [string, string]][] +>multiRobots : MultiSkilledRobot[] console.log(nameB); >console.log(nameB) : void @@ -233,8 +233,8 @@ for ([nameB] of multiRobots) { for ([nameB] of getMultiRobots()) { >[nameB] : [string] >nameB : string ->getMultiRobots() : [string, [string, string]][] ->getMultiRobots : () => [string, [string, string]][] +>getMultiRobots() : MultiSkilledRobot[] +>getMultiRobots : () => MultiSkilledRobot[] console.log(nameB); >console.log(nameB) : void @@ -246,9 +246,9 @@ for ([nameB] of getMultiRobots()) { for ([nameB] of [multiRobotA, multiRobotB]) { >[nameB] : [string] >nameB : string ->[multiRobotA, multiRobotB] : [string, [string, string]][] ->multiRobotA : [string, [string, string]] ->multiRobotB : [string, [string, string]] +>[multiRobotA, multiRobotB] : MultiSkilledRobot[] +>multiRobotA : MultiSkilledRobot +>multiRobotB : MultiSkilledRobot console.log(nameB); >console.log(nameB) : void @@ -263,7 +263,7 @@ for ([numberA2, nameA2, skillA2] of robots) { >numberA2 : number >nameA2 : string >skillA2 : string ->robots : [number, string, string][] +>robots : Robot[] console.log(nameA2); >console.log(nameA2) : void @@ -277,8 +277,8 @@ for ([numberA2, nameA2, skillA2] of getRobots()) { >numberA2 : number >nameA2 : string >skillA2 : string ->getRobots() : [number, string, string][] ->getRobots : () => [number, string, string][] +>getRobots() : Robot[] +>getRobots : () => Robot[] console.log(nameA2); >console.log(nameA2) : void @@ -292,9 +292,9 @@ for ([numberA2, nameA2, skillA2] of [robotA, robotB]) { >numberA2 : number >nameA2 : string >skillA2 : string ->[robotA, robotB] : [number, string, string][] ->robotA : [number, string, string] ->robotB : [number, string, string] +>[robotA, robotB] : Robot[] +>robotA : Robot +>robotB : Robot console.log(nameA2); >console.log(nameA2) : void @@ -309,7 +309,7 @@ for ([nameMA, [primarySkillA, secondarySkillA]] of multiRobots) { >[primarySkillA, secondarySkillA] : [string, string] >primarySkillA : string >secondarySkillA : string ->multiRobots : [string, [string, string]][] +>multiRobots : MultiSkilledRobot[] console.log(nameMA); >console.log(nameMA) : void @@ -324,8 +324,8 @@ for ([nameMA, [primarySkillA, secondarySkillA]] of getMultiRobots()) { >[primarySkillA, secondarySkillA] : [string, string] >primarySkillA : string >secondarySkillA : string ->getMultiRobots() : [string, [string, string]][] ->getMultiRobots : () => [string, [string, string]][] +>getMultiRobots() : MultiSkilledRobot[] +>getMultiRobots : () => MultiSkilledRobot[] console.log(nameMA); >console.log(nameMA) : void @@ -340,9 +340,9 @@ for ([nameMA, [primarySkillA, secondarySkillA]] of [multiRobotA, multiRobotB]) { >[primarySkillA, secondarySkillA] : [string, string] >primarySkillA : string >secondarySkillA : string ->[multiRobotA, multiRobotB] : [string, [string, string]][] ->multiRobotA : [string, [string, string]] ->multiRobotB : [string, [string, string]] +>[multiRobotA, multiRobotB] : MultiSkilledRobot[] +>multiRobotA : MultiSkilledRobot +>multiRobotB : MultiSkilledRobot console.log(nameMA); >console.log(nameMA) : void @@ -357,7 +357,7 @@ for ([numberA3, ...robotAInfo] of robots) { >numberA3 : number >...robotAInfo : string | number >robotAInfo : (string | number)[] ->robots : [number, string, string][] +>robots : Robot[] console.log(numberA3); >console.log(numberA3) : void @@ -371,8 +371,8 @@ for ([numberA3, ...robotAInfo] of getRobots()) { >numberA3 : number >...robotAInfo : string | number >robotAInfo : (string | number)[] ->getRobots() : [number, string, string][] ->getRobots : () => [number, string, string][] +>getRobots() : Robot[] +>getRobots : () => Robot[] console.log(numberA3); >console.log(numberA3) : void @@ -386,9 +386,9 @@ for ([numberA3, ...robotAInfo] of [robotA, robotB]) { >numberA3 : number >...robotAInfo : string | number >robotAInfo : (string | number)[] ->[robotA, robotB] : [number, string, string][] ->robotA : [number, string, string] ->robotB : [number, string, string] +>[robotA, robotB] : Robot[] +>robotA : Robot +>robotB : Robot console.log(numberA3); >console.log(numberA3) : void @@ -401,7 +401,7 @@ for ([...multiRobotAInfo] of multiRobots) { >[...multiRobotAInfo] : (string | [string, string])[] >...multiRobotAInfo : string | [string, string] >multiRobotAInfo : (string | [string, string])[] ->multiRobots : [string, [string, string]][] +>multiRobots : MultiSkilledRobot[] console.log(multiRobotAInfo); >console.log(multiRobotAInfo) : void @@ -414,8 +414,8 @@ for ([...multiRobotAInfo] of getMultiRobots()) { >[...multiRobotAInfo] : (string | [string, string])[] >...multiRobotAInfo : string | [string, string] >multiRobotAInfo : (string | [string, string])[] ->getMultiRobots() : [string, [string, string]][] ->getMultiRobots : () => [string, [string, string]][] +>getMultiRobots() : MultiSkilledRobot[] +>getMultiRobots : () => MultiSkilledRobot[] console.log(multiRobotAInfo); >console.log(multiRobotAInfo) : void @@ -428,9 +428,9 @@ for ([...multiRobotAInfo] of [multiRobotA, multiRobotB]) { >[...multiRobotAInfo] : (string | [string, string])[] >...multiRobotAInfo : string | [string, string] >multiRobotAInfo : (string | [string, string])[] ->[multiRobotA, multiRobotB] : [string, [string, string]][] ->multiRobotA : [string, [string, string]] ->multiRobotB : [string, [string, string]] +>[multiRobotA, multiRobotB] : MultiSkilledRobot[] +>multiRobotA : MultiSkilledRobot +>multiRobotB : MultiSkilledRobot console.log(multiRobotAInfo); >console.log(multiRobotAInfo) : void diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues.types b/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues.types index 34689acf920..cab4cc5ba07 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues.types @@ -7,40 +7,40 @@ declare var console: { >msg : any } type Robot = [number, string, string]; ->Robot : [number, string, string] +>Robot : Robot type MultiSkilledRobot = [string, [string, string]]; ->MultiSkilledRobot : [string, [string, string]] +>MultiSkilledRobot : MultiSkilledRobot let robotA: Robot = [1, "mower", "mowing"]; ->robotA : [number, string, string] +>robotA : Robot >[1, "mower", "mowing"] : [number, string, string] >1 : 1 >"mower" : "mower" >"mowing" : "mowing" let robotB: Robot = [2, "trimmer", "trimming"]; ->robotB : [number, string, string] +>robotB : Robot >[2, "trimmer", "trimming"] : [number, string, string] >2 : 2 >"trimmer" : "trimmer" >"trimming" : "trimming" let robots = [robotA, robotB]; ->robots : [number, string, string][] ->[robotA, robotB] : [number, string, string][] ->robotA : [number, string, string] ->robotB : [number, string, string] +>robots : Robot[] +>[robotA, robotB] : Robot[] +>robotA : Robot +>robotB : Robot function getRobots() { ->getRobots : () => [number, string, string][] +>getRobots : () => Robot[] return robots; ->robots : [number, string, string][] +>robots : Robot[] } let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot >["mower", ["mowing", ""]] : [string, [string, string]] >"mower" : "mower" >["mowing", ""] : [string, string] @@ -48,7 +48,7 @@ let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >"" : "" let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; ->multiRobotB : [string, [string, string]] +>multiRobotB : MultiSkilledRobot >["trimmer", ["trimming", "edging"]] : [string, [string, string]] >"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] @@ -56,23 +56,23 @@ let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; >"edging" : "edging" let multiRobots = [multiRobotA, multiRobotB]; ->multiRobots : [string, [string, string]][] ->[multiRobotA, multiRobotB] : [string, [string, string]][] ->multiRobotA : [string, [string, string]] ->multiRobotB : [string, [string, string]] +>multiRobots : MultiSkilledRobot[] +>[multiRobotA, multiRobotB] : MultiSkilledRobot[] +>multiRobotA : MultiSkilledRobot +>multiRobotB : MultiSkilledRobot function getMultiRobots() { ->getMultiRobots : () => [string, [string, string]][] +>getMultiRobots : () => MultiSkilledRobot[] return multiRobots; ->multiRobots : [string, [string, string]][] +>multiRobots : MultiSkilledRobot[] } for (let [, nameA = "noName"] of robots) { > : undefined >nameA : string >"noName" : "noName" ->robots : [number, string, string][] +>robots : Robot[] console.log(nameA); >console.log(nameA) : void @@ -85,8 +85,8 @@ for (let [, nameA = "noName"] of getRobots()) { > : undefined >nameA : string >"noName" : "noName" ->getRobots() : [number, string, string][] ->getRobots : () => [number, string, string][] +>getRobots() : Robot[] +>getRobots : () => Robot[] console.log(nameA); >console.log(nameA) : void @@ -99,9 +99,9 @@ for (let [, nameA = "noName"] of [robotA, robotB]) { > : undefined >nameA : string >"noName" : "noName" ->[robotA, robotB] : [number, string, string][] ->robotA : [number, string, string] ->robotB : [number, string, string] +>[robotA, robotB] : Robot[] +>robotA : Robot +>robotB : Robot console.log(nameA); >console.log(nameA) : void @@ -125,7 +125,7 @@ for (let [, [ >["skill1", "skill2"] : [string, string] >"skill1" : "skill1" >"skill2" : "skill2" ->multiRobots : [string, [string, string]][] +>multiRobots : MultiSkilledRobot[] console.log(primarySkillA); >console.log(primarySkillA) : void @@ -149,8 +149,8 @@ for (let [, [ >["skill1", "skill2"] : [string, string] >"skill1" : "skill1" >"skill2" : "skill2" ->getMultiRobots() : [string, [string, string]][] ->getMultiRobots : () => [string, [string, string]][] +>getMultiRobots() : MultiSkilledRobot[] +>getMultiRobots : () => MultiSkilledRobot[] console.log(primarySkillA); >console.log(primarySkillA) : void @@ -174,9 +174,9 @@ for (let [, [ >["skill1", "skill2"] : [string, string] >"skill1" : "skill1" >"skill2" : "skill2" ->[multiRobotA, multiRobotB] : [string, [string, string]][] ->multiRobotA : [string, [string, string]] ->multiRobotB : [string, [string, string]] +>[multiRobotA, multiRobotB] : MultiSkilledRobot[] +>multiRobotA : MultiSkilledRobot +>multiRobotB : MultiSkilledRobot console.log(primarySkillA); >console.log(primarySkillA) : void @@ -190,7 +190,7 @@ for (let [numberB = -1] of robots) { >numberB : number >-1 : -1 >1 : 1 ->robots : [number, string, string][] +>robots : Robot[] console.log(numberB); >console.log(numberB) : void @@ -203,8 +203,8 @@ for (let [numberB = -1] of getRobots()) { >numberB : number >-1 : -1 >1 : 1 ->getRobots() : [number, string, string][] ->getRobots : () => [number, string, string][] +>getRobots() : Robot[] +>getRobots : () => Robot[] console.log(numberB); >console.log(numberB) : void @@ -217,9 +217,9 @@ for (let [numberB = -1] of [robotA, robotB]) { >numberB : number >-1 : -1 >1 : 1 ->[robotA, robotB] : [number, string, string][] ->robotA : [number, string, string] ->robotB : [number, string, string] +>[robotA, robotB] : Robot[] +>robotA : Robot +>robotB : Robot console.log(numberB); >console.log(numberB) : void @@ -231,7 +231,7 @@ for (let [numberB = -1] of [robotA, robotB]) { for (let [nameB = "noName"] of multiRobots) { >nameB : string >"noName" : "noName" ->multiRobots : [string, [string, string]][] +>multiRobots : MultiSkilledRobot[] console.log(nameB); >console.log(nameB) : void @@ -243,8 +243,8 @@ for (let [nameB = "noName"] of multiRobots) { for (let [nameB = "noName"] of getMultiRobots()) { >nameB : string >"noName" : "noName" ->getMultiRobots() : [string, [string, string]][] ->getMultiRobots : () => [string, [string, string]][] +>getMultiRobots() : MultiSkilledRobot[] +>getMultiRobots : () => MultiSkilledRobot[] console.log(nameB); >console.log(nameB) : void @@ -256,9 +256,9 @@ for (let [nameB = "noName"] of getMultiRobots()) { for (let [nameB = "noName"] of [multiRobotA, multiRobotB]) { >nameB : string >"noName" : "noName" ->[multiRobotA, multiRobotB] : [string, [string, string]][] ->multiRobotA : [string, [string, string]] ->multiRobotB : [string, [string, string]] +>[multiRobotA, multiRobotB] : MultiSkilledRobot[] +>multiRobotA : MultiSkilledRobot +>multiRobotB : MultiSkilledRobot console.log(nameB); >console.log(nameB) : void @@ -276,7 +276,7 @@ for (let [numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] of robots) { >"noName" : "noName" >skillA2 : string >"skill" : "skill" ->robots : [number, string, string][] +>robots : Robot[] console.log(nameA2); >console.log(nameA2) : void @@ -293,8 +293,8 @@ for (let [numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] of getRobots()) { >"noName" : "noName" >skillA2 : string >"skill" : "skill" ->getRobots() : [number, string, string][] ->getRobots : () => [number, string, string][] +>getRobots() : Robot[] +>getRobots : () => Robot[] console.log(nameA2); >console.log(nameA2) : void @@ -311,9 +311,9 @@ for (let [numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] of [robotA, robot >"noName" : "noName" >skillA2 : string >"skill" : "skill" ->[robotA, robotB] : [number, string, string][] ->robotA : [number, string, string] ->robotB : [number, string, string] +>[robotA, robotB] : Robot[] +>robotA : Robot +>robotB : Robot console.log(nameA2); >console.log(nameA2) : void @@ -338,7 +338,7 @@ for (let [nameMA = "noName", [ >["skill1", "skill2"] : [string, string] >"skill1" : "skill1" >"skill2" : "skill2" ->multiRobots : [string, [string, string]][] +>multiRobots : MultiSkilledRobot[] console.log(nameMA); >console.log(nameMA) : void @@ -363,8 +363,8 @@ for (let [nameMA = "noName", [ >["skill1", "skill2"] : [string, string] >"skill1" : "skill1" >"skill2" : "skill2" ->getMultiRobots() : [string, [string, string]][] ->getMultiRobots : () => [string, [string, string]][] +>getMultiRobots() : MultiSkilledRobot[] +>getMultiRobots : () => MultiSkilledRobot[] console.log(nameMA); >console.log(nameMA) : void @@ -389,9 +389,9 @@ for (let [nameMA = "noName", [ >["skill1", "skill2"] : [string, string] >"skill1" : "skill1" >"skill2" : "skill2" ->[multiRobotA, multiRobotB] : [string, [string, string]][] ->multiRobotA : [string, [string, string]] ->multiRobotB : [string, [string, string]] +>[multiRobotA, multiRobotB] : MultiSkilledRobot[] +>multiRobotA : MultiSkilledRobot +>multiRobotB : MultiSkilledRobot console.log(nameMA); >console.log(nameMA) : void @@ -406,7 +406,7 @@ for (let [numberA3 = -1, ...robotAInfo] of robots) { >-1 : -1 >1 : 1 >robotAInfo : [string, string] ->robots : [number, string, string][] +>robots : Robot[] console.log(numberA3); >console.log(numberA3) : void @@ -420,8 +420,8 @@ for (let [numberA3 = -1, ...robotAInfo] of getRobots()) { >-1 : -1 >1 : 1 >robotAInfo : [string, string] ->getRobots() : [number, string, string][] ->getRobots : () => [number, string, string][] +>getRobots() : Robot[] +>getRobots : () => Robot[] console.log(numberA3); >console.log(numberA3) : void @@ -435,9 +435,9 @@ for (let [numberA3 = -1, ...robotAInfo] of [robotA, robotB]) { >-1 : -1 >1 : 1 >robotAInfo : [string, string] ->[robotA, robotB] : [number, string, string][] ->robotA : [number, string, string] ->robotB : [number, string, string] +>[robotA, robotB] : Robot[] +>robotA : Robot +>robotB : Robot console.log(numberA3); >console.log(numberA3) : void diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues2.types b/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues2.types index ffca2d37c89..14e0bbaa335 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues2.types @@ -7,40 +7,40 @@ declare var console: { >msg : any } type Robot = [number, string, string]; ->Robot : [number, string, string] +>Robot : Robot type MultiSkilledRobot = [string, [string, string]]; ->MultiSkilledRobot : [string, [string, string]] +>MultiSkilledRobot : MultiSkilledRobot let robotA: Robot = [1, "mower", "mowing"]; ->robotA : [number, string, string] +>robotA : Robot >[1, "mower", "mowing"] : [number, string, string] >1 : 1 >"mower" : "mower" >"mowing" : "mowing" let robotB: Robot = [2, "trimmer", "trimming"]; ->robotB : [number, string, string] +>robotB : Robot >[2, "trimmer", "trimming"] : [number, string, string] >2 : 2 >"trimmer" : "trimmer" >"trimming" : "trimming" let robots = [robotA, robotB]; ->robots : [number, string, string][] ->[robotA, robotB] : [number, string, string][] ->robotA : [number, string, string] ->robotB : [number, string, string] +>robots : Robot[] +>[robotA, robotB] : Robot[] +>robotA : Robot +>robotB : Robot function getRobots() { ->getRobots : () => [number, string, string][] +>getRobots : () => Robot[] return robots; ->robots : [number, string, string][] +>robots : Robot[] } let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot >["mower", ["mowing", ""]] : [string, [string, string]] >"mower" : "mower" >["mowing", ""] : [string, string] @@ -48,7 +48,7 @@ let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >"" : "" let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; ->multiRobotB : [string, [string, string]] +>multiRobotB : MultiSkilledRobot >["trimmer", ["trimming", "edging"]] : [string, [string, string]] >"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] @@ -56,16 +56,16 @@ let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; >"edging" : "edging" let multiRobots = [multiRobotA, multiRobotB]; ->multiRobots : [string, [string, string]][] ->[multiRobotA, multiRobotB] : [string, [string, string]][] ->multiRobotA : [string, [string, string]] ->multiRobotB : [string, [string, string]] +>multiRobots : MultiSkilledRobot[] +>[multiRobotA, multiRobotB] : MultiSkilledRobot[] +>multiRobotA : MultiSkilledRobot +>multiRobotB : MultiSkilledRobot function getMultiRobots() { ->getMultiRobots : () => [string, [string, string]][] +>getMultiRobots : () => MultiSkilledRobot[] return multiRobots; ->multiRobots : [string, [string, string]][] +>multiRobots : MultiSkilledRobot[] } let nameA: string, primarySkillA: string, secondarySkillA: string; @@ -94,7 +94,7 @@ for ([, nameA = "noName"] of robots) { >nameA = "noName" : "noName" >nameA : string >"noName" : "noName" ->robots : [number, string, string][] +>robots : Robot[] console.log(nameA); >console.log(nameA) : void @@ -109,8 +109,8 @@ for ([, nameA = "noName"] of getRobots()) { >nameA = "noName" : "noName" >nameA : string >"noName" : "noName" ->getRobots() : [number, string, string][] ->getRobots : () => [number, string, string][] +>getRobots() : Robot[] +>getRobots : () => Robot[] console.log(nameA); >console.log(nameA) : void @@ -125,9 +125,9 @@ for ([, nameA = "noName"] of [robotA, robotB]) { >nameA = "noName" : "noName" >nameA : string >"noName" : "noName" ->[robotA, robotB] : [number, string, string][] ->robotA : [number, string, string] ->robotB : [number, string, string] +>[robotA, robotB] : Robot[] +>robotA : Robot +>robotB : Robot console.log(nameA); >console.log(nameA) : void @@ -156,7 +156,7 @@ for ([, [ >["skill1", "skill2"] : [string, string] >"skill1" : "skill1" >"skill2" : "skill2" ->multiRobots : [string, [string, string]][] +>multiRobots : MultiSkilledRobot[] console.log(primarySkillA); >console.log(primarySkillA) : void @@ -185,8 +185,8 @@ for ([, [ >["skill1", "skill2"] : [string, string] >"skill1" : "skill1" >"skill2" : "skill2" ->getMultiRobots() : [string, [string, string]][] ->getMultiRobots : () => [string, [string, string]][] +>getMultiRobots() : MultiSkilledRobot[] +>getMultiRobots : () => MultiSkilledRobot[] console.log(primarySkillA); >console.log(primarySkillA) : void @@ -215,9 +215,9 @@ for ([, [ >["skill1", "skill2"] : [string, string] >"skill1" : "skill1" >"skill2" : "skill2" ->[multiRobotA, multiRobotB] : [string, [string, string]][] ->multiRobotA : [string, [string, string]] ->multiRobotB : [string, [string, string]] +>[multiRobotA, multiRobotB] : MultiSkilledRobot[] +>multiRobotA : MultiSkilledRobot +>multiRobotB : MultiSkilledRobot console.log(primarySkillA); >console.log(primarySkillA) : void @@ -233,7 +233,7 @@ for ([numberB = -1] of robots) { >numberB : number >-1 : -1 >1 : 1 ->robots : [number, string, string][] +>robots : Robot[] console.log(numberB); >console.log(numberB) : void @@ -248,8 +248,8 @@ for ([numberB = -1] of getRobots()) { >numberB : number >-1 : -1 >1 : 1 ->getRobots() : [number, string, string][] ->getRobots : () => [number, string, string][] +>getRobots() : Robot[] +>getRobots : () => Robot[] console.log(numberB); >console.log(numberB) : void @@ -264,9 +264,9 @@ for ([numberB = -1] of [robotA, robotB]) { >numberB : number >-1 : -1 >1 : 1 ->[robotA, robotB] : [number, string, string][] ->robotA : [number, string, string] ->robotB : [number, string, string] +>[robotA, robotB] : Robot[] +>robotA : Robot +>robotB : Robot console.log(numberB); >console.log(numberB) : void @@ -280,7 +280,7 @@ for ([nameB = "noName"] of multiRobots) { >nameB = "noName" : "noName" >nameB : string >"noName" : "noName" ->multiRobots : [string, [string, string]][] +>multiRobots : MultiSkilledRobot[] console.log(nameB); >console.log(nameB) : void @@ -294,8 +294,8 @@ for ([nameB = "noName"] of getMultiRobots()) { >nameB = "noName" : "noName" >nameB : string >"noName" : "noName" ->getMultiRobots() : [string, [string, string]][] ->getMultiRobots : () => [string, [string, string]][] +>getMultiRobots() : MultiSkilledRobot[] +>getMultiRobots : () => MultiSkilledRobot[] console.log(nameB); >console.log(nameB) : void @@ -309,9 +309,9 @@ for ([nameB = "noName"] of [multiRobotA, multiRobotB]) { >nameB = "noName" : "noName" >nameB : string >"noName" : "noName" ->[multiRobotA, multiRobotB] : [string, [string, string]][] ->multiRobotA : [string, [string, string]] ->multiRobotB : [string, [string, string]] +>[multiRobotA, multiRobotB] : MultiSkilledRobot[] +>multiRobotA : MultiSkilledRobot +>multiRobotB : MultiSkilledRobot console.log(nameB); >console.log(nameB) : void @@ -333,7 +333,7 @@ for ([numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] of robots) { >skillA2 = "skill" : "skill" >skillA2 : string >"skill" : "skill" ->robots : [number, string, string][] +>robots : Robot[] console.log(nameA2); >console.log(nameA2) : void @@ -354,8 +354,8 @@ for ([numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] of getRobots()) { >skillA2 = "skill" : "skill" >skillA2 : string >"skill" : "skill" ->getRobots() : [number, string, string][] ->getRobots : () => [number, string, string][] +>getRobots() : Robot[] +>getRobots : () => Robot[] console.log(nameA2); >console.log(nameA2) : void @@ -376,9 +376,9 @@ for ([numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] of [robotA, robotB]) >skillA2 = "skill" : "skill" >skillA2 : string >"skill" : "skill" ->[robotA, robotB] : [number, string, string][] ->robotA : [number, string, string] ->robotB : [number, string, string] +>[robotA, robotB] : Robot[] +>robotA : Robot +>robotB : Robot console.log(nameA2); >console.log(nameA2) : void @@ -409,7 +409,7 @@ for ([nameMA = "noName", [ >["skill1", "skill2"] : [string, string] >"skill1" : "skill1" >"skill2" : "skill2" ->multiRobots : [string, [string, string]][] +>multiRobots : MultiSkilledRobot[] console.log(nameMA); >console.log(nameMA) : void @@ -440,8 +440,8 @@ for ([nameMA = "noName", [ >["skill1", "skill2"] : [string, string] >"skill1" : "skill1" >"skill2" : "skill2" ->getMultiRobots() : [string, [string, string]][] ->getMultiRobots : () => [string, [string, string]][] +>getMultiRobots() : MultiSkilledRobot[] +>getMultiRobots : () => MultiSkilledRobot[] console.log(nameMA); >console.log(nameMA) : void @@ -472,9 +472,9 @@ for ([nameMA = "noName", [ >["skill1", "skill2"] : [string, string] >"skill1" : "skill1" >"skill2" : "skill2" ->[multiRobotA, multiRobotB] : [string, [string, string]][] ->multiRobotA : [string, [string, string]] ->multiRobotB : [string, [string, string]] +>[multiRobotA, multiRobotB] : MultiSkilledRobot[] +>multiRobotA : MultiSkilledRobot +>multiRobotB : MultiSkilledRobot console.log(nameMA); >console.log(nameMA) : void @@ -492,7 +492,7 @@ for ([numberA3 = -1, ...robotAInfo] of robots) { >1 : 1 >...robotAInfo : string | number >robotAInfo : (string | number)[] ->robots : [number, string, string][] +>robots : Robot[] console.log(numberA3); >console.log(numberA3) : void @@ -509,8 +509,8 @@ for ([numberA3 = -1, ...robotAInfo] of getRobots()) { >1 : 1 >...robotAInfo : string | number >robotAInfo : (string | number)[] ->getRobots() : [number, string, string][] ->getRobots : () => [number, string, string][] +>getRobots() : Robot[] +>getRobots : () => Robot[] console.log(numberA3); >console.log(numberA3) : void @@ -527,9 +527,9 @@ for ([numberA3 = -1, ...robotAInfo] of [robotA, robotB]) { >1 : 1 >...robotAInfo : string | number >robotAInfo : (string | number)[] ->[robotA, robotB] : [number, string, string][] ->robotA : [number, string, string] ->robotB : [number, string, string] +>[robotA, robotB] : Robot[] +>robotA : Robot +>robotB : Robot console.log(numberA3); >console.log(numberA3) : void diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern.types b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern.types index 2758457edbe..ff955abe34b 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern.types @@ -7,17 +7,17 @@ declare var console: { >msg : any } type Robot = [number, string, string]; ->Robot : [number, string, string] +>Robot : Robot var robotA: Robot = [1, "mower", "mowing"]; ->robotA : [number, string, string] +>robotA : Robot >[1, "mower", "mowing"] : [number, string, string] >1 : 1 >"mower" : "mower" >"mowing" : "mowing" function foo1([, nameA]: Robot) { ->foo1 : ([, nameA]: [number, string, string]) => void +>foo1 : ([, nameA]: Robot) => void > : undefined >nameA : string @@ -30,7 +30,7 @@ function foo1([, nameA]: Robot) { } function foo2([numberB]: Robot) { ->foo2 : ([numberB]: [number, string, string]) => void +>foo2 : ([numberB]: Robot) => void >numberB : number console.log(numberB); @@ -42,7 +42,7 @@ function foo2([numberB]: Robot) { } function foo3([numberA2, nameA2, skillA2]: Robot) { ->foo3 : ([numberA2, nameA2, skillA2]: [number, string, string]) => void +>foo3 : ([numberA2, nameA2, skillA2]: Robot) => void >numberA2 : number >nameA2 : string >skillA2 : string @@ -56,7 +56,7 @@ function foo3([numberA2, nameA2, skillA2]: Robot) { } function foo4([numberA3, ...robotAInfo]: Robot) { ->foo4 : ([numberA3, ...robotAInfo]: [number, string, string]) => void +>foo4 : ([numberA3, ...robotAInfo]: Robot) => void >numberA3 : number >robotAInfo : [string, string] @@ -70,12 +70,12 @@ function foo4([numberA3, ...robotAInfo]: Robot) { foo1(robotA); >foo1(robotA) : void ->foo1 : ([, nameA]: [number, string, string]) => void ->robotA : [number, string, string] +>foo1 : ([, nameA]: Robot) => void +>robotA : Robot foo1([2, "trimmer", "trimming"]); >foo1([2, "trimmer", "trimming"]) : void ->foo1 : ([, nameA]: [number, string, string]) => void +>foo1 : ([, nameA]: Robot) => void >[2, "trimmer", "trimming"] : [number, string, string] >2 : 2 >"trimmer" : "trimmer" @@ -83,12 +83,12 @@ foo1([2, "trimmer", "trimming"]); foo2(robotA); >foo2(robotA) : void ->foo2 : ([numberB]: [number, string, string]) => void ->robotA : [number, string, string] +>foo2 : ([numberB]: Robot) => void +>robotA : Robot foo2([2, "trimmer", "trimming"]); >foo2([2, "trimmer", "trimming"]) : void ->foo2 : ([numberB]: [number, string, string]) => void +>foo2 : ([numberB]: Robot) => void >[2, "trimmer", "trimming"] : [number, string, string] >2 : 2 >"trimmer" : "trimmer" @@ -96,12 +96,12 @@ foo2([2, "trimmer", "trimming"]); foo3(robotA); >foo3(robotA) : void ->foo3 : ([numberA2, nameA2, skillA2]: [number, string, string]) => void ->robotA : [number, string, string] +>foo3 : ([numberA2, nameA2, skillA2]: Robot) => void +>robotA : Robot foo3([2, "trimmer", "trimming"]); >foo3([2, "trimmer", "trimming"]) : void ->foo3 : ([numberA2, nameA2, skillA2]: [number, string, string]) => void +>foo3 : ([numberA2, nameA2, skillA2]: Robot) => void >[2, "trimmer", "trimming"] : [number, string, string] >2 : 2 >"trimmer" : "trimmer" @@ -109,12 +109,12 @@ foo3([2, "trimmer", "trimming"]); foo4(robotA); >foo4(robotA) : void ->foo4 : ([numberA3, ...robotAInfo]: [number, string, string]) => void ->robotA : [number, string, string] +>foo4 : ([numberA3, ...robotAInfo]: Robot) => void +>robotA : Robot foo4([2, "trimmer", "trimming"]); >foo4([2, "trimmer", "trimming"]) : void ->foo4 : ([numberA3, ...robotAInfo]: [number, string, string]) => void +>foo4 : ([numberA3, ...robotAInfo]: Robot) => void >[2, "trimmer", "trimming"] : [number, string, string] >2 : 2 >"trimmer" : "trimmer" diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern2.types b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern2.types index 1cdced45404..aee226f8d83 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern2.types @@ -7,10 +7,10 @@ declare var console: { >msg : any } type Robot = [string, [string, string]]; ->Robot : [string, [string, string]] +>Robot : Robot var robotA: Robot = ["trimmer", ["trimming", "edging"]]; ->robotA : [string, [string, string]] +>robotA : Robot >["trimmer", ["trimming", "edging"]] : [string, [string, string]] >"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] @@ -18,7 +18,7 @@ var robotA: Robot = ["trimmer", ["trimming", "edging"]]; >"edging" : "edging" function foo1([, skillA]: Robot) { ->foo1 : ([, skillA]: [string, [string, string]]) => void +>foo1 : ([, skillA]: Robot) => void > : undefined >skillA : [string, string] @@ -31,7 +31,7 @@ function foo1([, skillA]: Robot) { } function foo2([nameMB]: Robot) { ->foo2 : ([nameMB]: [string, [string, string]]) => void +>foo2 : ([nameMB]: Robot) => void >nameMB : string console.log(nameMB); @@ -43,7 +43,7 @@ function foo2([nameMB]: Robot) { } function foo3([nameMA, [primarySkillA, secondarySkillA]]: Robot) { ->foo3 : ([nameMA, [primarySkillA, secondarySkillA]]: [string, [string, string]]) => void +>foo3 : ([nameMA, [primarySkillA, secondarySkillA]]: Robot) => void >nameMA : string >primarySkillA : string >secondarySkillA : string @@ -57,7 +57,7 @@ function foo3([nameMA, [primarySkillA, secondarySkillA]]: Robot) { } function foo4([...multiRobotAInfo]: Robot) { ->foo4 : ([...multiRobotAInfo]: [string, [string, string]]) => void +>foo4 : ([...multiRobotAInfo]: Robot) => void >multiRobotAInfo : [string, [string, string]] console.log(multiRobotAInfo); @@ -70,12 +70,12 @@ function foo4([...multiRobotAInfo]: Robot) { foo1(robotA); >foo1(robotA) : void ->foo1 : ([, skillA]: [string, [string, string]]) => void ->robotA : [string, [string, string]] +>foo1 : ([, skillA]: Robot) => void +>robotA : Robot foo1(["roomba", ["vaccum", "mopping"]]); >foo1(["roomba", ["vaccum", "mopping"]]) : void ->foo1 : ([, skillA]: [string, [string, string]]) => void +>foo1 : ([, skillA]: Robot) => void >["roomba", ["vaccum", "mopping"]] : [string, [string, string]] >"roomba" : "roomba" >["vaccum", "mopping"] : [string, string] @@ -84,12 +84,12 @@ foo1(["roomba", ["vaccum", "mopping"]]); foo2(robotA); >foo2(robotA) : void ->foo2 : ([nameMB]: [string, [string, string]]) => void ->robotA : [string, [string, string]] +>foo2 : ([nameMB]: Robot) => void +>robotA : Robot foo2(["roomba", ["vaccum", "mopping"]]); >foo2(["roomba", ["vaccum", "mopping"]]) : void ->foo2 : ([nameMB]: [string, [string, string]]) => void +>foo2 : ([nameMB]: Robot) => void >["roomba", ["vaccum", "mopping"]] : [string, [string, string]] >"roomba" : "roomba" >["vaccum", "mopping"] : [string, string] @@ -98,12 +98,12 @@ foo2(["roomba", ["vaccum", "mopping"]]); foo3(robotA); >foo3(robotA) : void ->foo3 : ([nameMA, [primarySkillA, secondarySkillA]]: [string, [string, string]]) => void ->robotA : [string, [string, string]] +>foo3 : ([nameMA, [primarySkillA, secondarySkillA]]: Robot) => void +>robotA : Robot foo3(["roomba", ["vaccum", "mopping"]]); >foo3(["roomba", ["vaccum", "mopping"]]) : void ->foo3 : ([nameMA, [primarySkillA, secondarySkillA]]: [string, [string, string]]) => void +>foo3 : ([nameMA, [primarySkillA, secondarySkillA]]: Robot) => void >["roomba", ["vaccum", "mopping"]] : [string, [string, string]] >"roomba" : "roomba" >["vaccum", "mopping"] : [string, string] @@ -112,12 +112,12 @@ foo3(["roomba", ["vaccum", "mopping"]]); foo4(robotA); >foo4(robotA) : void ->foo4 : ([...multiRobotAInfo]: [string, [string, string]]) => void ->robotA : [string, [string, string]] +>foo4 : ([...multiRobotAInfo]: Robot) => void +>robotA : Robot foo4(["roomba", ["vaccum", "mopping"]]); >foo4(["roomba", ["vaccum", "mopping"]]) : void ->foo4 : ([...multiRobotAInfo]: [string, [string, string]]) => void +>foo4 : ([...multiRobotAInfo]: Robot) => void >["roomba", ["vaccum", "mopping"]] : [string, [string, string]] >"roomba" : "roomba" >["vaccum", "mopping"] : [string, string] diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues.types b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues.types index 60345aa2b73..94106255a12 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues.types @@ -7,17 +7,17 @@ declare var console: { >msg : any } type Robot = [number, string, string]; ->Robot : [number, string, string] +>Robot : Robot var robotA: Robot = [1, "mower", "mowing"]; ->robotA : [number, string, string] +>robotA : Robot >[1, "mower", "mowing"] : [number, string, string] >1 : 1 >"mower" : "mower" >"mowing" : "mowing" function foo1([, nameA = "noName"]: Robot = [-1, "name", "skill"]) { ->foo1 : ([, nameA]?: [number, string, string]) => void +>foo1 : ([, nameA]?: Robot) => void > : undefined >nameA : string >"noName" : "noName" @@ -36,7 +36,7 @@ function foo1([, nameA = "noName"]: Robot = [-1, "name", "skill"]) { } function foo2([numberB = -1]: Robot = [-1, "name", "skill"]) { ->foo2 : ([numberB]?: [number, string, string]) => void +>foo2 : ([numberB]?: Robot) => void >numberB : number >-1 : -1 >1 : 1 @@ -55,7 +55,7 @@ function foo2([numberB = -1]: Robot = [-1, "name", "skill"]) { } function foo3([numberA2 = -1, nameA2 = "name", skillA2 = "skill"]: Robot = [-1, "name", "skill"]) { ->foo3 : ([numberA2, nameA2, skillA2]?: [number, string, string]) => void +>foo3 : ([numberA2, nameA2, skillA2]?: Robot) => void >numberA2 : number >-1 : -1 >1 : 1 @@ -78,7 +78,7 @@ function foo3([numberA2 = -1, nameA2 = "name", skillA2 = "skill"]: Robot = [-1, } function foo4([numberA3 = -1, ...robotAInfo]: Robot = [-1, "name", "skill"]) { ->foo4 : ([numberA3, ...robotAInfo]?: [number, string, string]) => void +>foo4 : ([numberA3, ...robotAInfo]?: Robot) => void >numberA3 : number >-1 : -1 >1 : 1 @@ -99,12 +99,12 @@ function foo4([numberA3 = -1, ...robotAInfo]: Robot = [-1, "name", "skill"]) { foo1(robotA); >foo1(robotA) : void ->foo1 : ([, nameA]?: [number, string, string]) => void ->robotA : [number, string, string] +>foo1 : ([, nameA]?: Robot) => void +>robotA : Robot foo1([2, "trimmer", "trimming"]); >foo1([2, "trimmer", "trimming"]) : void ->foo1 : ([, nameA]?: [number, string, string]) => void +>foo1 : ([, nameA]?: Robot) => void >[2, "trimmer", "trimming"] : [number, string, string] >2 : 2 >"trimmer" : "trimmer" @@ -112,12 +112,12 @@ foo1([2, "trimmer", "trimming"]); foo2(robotA); >foo2(robotA) : void ->foo2 : ([numberB]?: [number, string, string]) => void ->robotA : [number, string, string] +>foo2 : ([numberB]?: Robot) => void +>robotA : Robot foo2([2, "trimmer", "trimming"]); >foo2([2, "trimmer", "trimming"]) : void ->foo2 : ([numberB]?: [number, string, string]) => void +>foo2 : ([numberB]?: Robot) => void >[2, "trimmer", "trimming"] : [number, string, string] >2 : 2 >"trimmer" : "trimmer" @@ -125,12 +125,12 @@ foo2([2, "trimmer", "trimming"]); foo3(robotA); >foo3(robotA) : void ->foo3 : ([numberA2, nameA2, skillA2]?: [number, string, string]) => void ->robotA : [number, string, string] +>foo3 : ([numberA2, nameA2, skillA2]?: Robot) => void +>robotA : Robot foo3([2, "trimmer", "trimming"]); >foo3([2, "trimmer", "trimming"]) : void ->foo3 : ([numberA2, nameA2, skillA2]?: [number, string, string]) => void +>foo3 : ([numberA2, nameA2, skillA2]?: Robot) => void >[2, "trimmer", "trimming"] : [number, string, string] >2 : 2 >"trimmer" : "trimmer" @@ -138,12 +138,12 @@ foo3([2, "trimmer", "trimming"]); foo4(robotA); >foo4(robotA) : void ->foo4 : ([numberA3, ...robotAInfo]?: [number, string, string]) => void ->robotA : [number, string, string] +>foo4 : ([numberA3, ...robotAInfo]?: Robot) => void +>robotA : Robot foo4([2, "trimmer", "trimming"]); >foo4([2, "trimmer", "trimming"]) : void ->foo4 : ([numberA3, ...robotAInfo]?: [number, string, string]) => void +>foo4 : ([numberA3, ...robotAInfo]?: Robot) => void >[2, "trimmer", "trimming"] : [number, string, string] >2 : 2 >"trimmer" : "trimmer" diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues2.types b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues2.types index d9c991f65fb..f2773f2d252 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues2.types @@ -7,10 +7,10 @@ declare var console: { >msg : any } type Robot = [string, string[]]; ->Robot : [string, string[]] +>Robot : Robot var robotA: Robot = ["trimmer", ["trimming", "edging"]]; ->robotA : [string, string[]] +>robotA : Robot >["trimmer", ["trimming", "edging"]] : [string, string[]] >"trimmer" : "trimmer" >["trimming", "edging"] : string[] @@ -18,7 +18,7 @@ var robotA: Robot = ["trimmer", ["trimming", "edging"]]; >"edging" : "edging" function foo1([, skillA = ["noSkill", "noSkill"]]: Robot= ["name", ["skill1", "skill2"]]) { ->foo1 : ([, skillA]?: [string, string[]]) => void +>foo1 : ([, skillA]?: Robot) => void > : undefined >skillA : string[] >["noSkill", "noSkill"] : string[] @@ -39,7 +39,7 @@ function foo1([, skillA = ["noSkill", "noSkill"]]: Robot= ["name", ["skill1", "s } function foo2([nameMB = "noName"]: Robot = ["name", ["skill1", "skill2"]]) { ->foo2 : ([nameMB]?: [string, string[]]) => void +>foo2 : ([nameMB]?: Robot) => void >nameMB : string >"noName" : "noName" >["name", ["skill1", "skill2"]] : [string, string[]] @@ -57,7 +57,7 @@ function foo2([nameMB = "noName"]: Robot = ["name", ["skill1", "skill2"]]) { } function foo3([nameMA = "noName", [ ->foo3 : ([nameMA, [primarySkillA, secondarySkillA]]: [string, string[]]) => void +>foo3 : ([nameMA, [primarySkillA, secondarySkillA]]: Robot) => void >nameMA : string >"noName" : "noName" @@ -84,12 +84,12 @@ function foo3([nameMA = "noName", [ foo1(robotA); >foo1(robotA) : void ->foo1 : ([, skillA]?: [string, string[]]) => void ->robotA : [string, string[]] +>foo1 : ([, skillA]?: Robot) => void +>robotA : Robot foo1(["roomba", ["vaccum", "mopping"]]); >foo1(["roomba", ["vaccum", "mopping"]]) : void ->foo1 : ([, skillA]?: [string, string[]]) => void +>foo1 : ([, skillA]?: Robot) => void >["roomba", ["vaccum", "mopping"]] : [string, string[]] >"roomba" : "roomba" >["vaccum", "mopping"] : string[] @@ -98,12 +98,12 @@ foo1(["roomba", ["vaccum", "mopping"]]); foo2(robotA); >foo2(robotA) : void ->foo2 : ([nameMB]?: [string, string[]]) => void ->robotA : [string, string[]] +>foo2 : ([nameMB]?: Robot) => void +>robotA : Robot foo2(["roomba", ["vaccum", "mopping"]]); >foo2(["roomba", ["vaccum", "mopping"]]) : void ->foo2 : ([nameMB]?: [string, string[]]) => void +>foo2 : ([nameMB]?: Robot) => void >["roomba", ["vaccum", "mopping"]] : [string, string[]] >"roomba" : "roomba" >["vaccum", "mopping"] : string[] @@ -112,12 +112,12 @@ foo2(["roomba", ["vaccum", "mopping"]]); foo3(robotA); >foo3(robotA) : void ->foo3 : ([nameMA, [primarySkillA, secondarySkillA]]: [string, string[]]) => void ->robotA : [string, string[]] +>foo3 : ([nameMA, [primarySkillA, secondarySkillA]]: Robot) => void +>robotA : Robot foo3(["roomba", ["vaccum", "mopping"]]); >foo3(["roomba", ["vaccum", "mopping"]]) : void ->foo3 : ([nameMA, [primarySkillA, secondarySkillA]]: [string, string[]]) => void +>foo3 : ([nameMA, [primarySkillA, secondarySkillA]]: Robot) => void >["roomba", ["vaccum", "mopping"]] : [string, string[]] >"roomba" : "roomba" >["vaccum", "mopping"] : string[] diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern.types index 2ed0777aa80..61e7f7ab3e2 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern.types @@ -7,17 +7,17 @@ declare var console: { >msg : string } type Robot = [number, string, string]; ->Robot : [number, string, string] +>Robot : Robot var robotA: Robot = [1, "mower", "mowing"]; ->robotA : [number, string, string] +>robotA : Robot >[1, "mower", "mowing"] : [number, string, string] >1 : 1 >"mower" : "mower" >"mowing" : "mowing" var robotB: Robot = [2, "trimmer", "trimming"]; ->robotB : [number, string, string] +>robotB : Robot >[2, "trimmer", "trimming"] : [number, string, string] >2 : 2 >"trimmer" : "trimmer" @@ -27,17 +27,17 @@ var robotB: Robot = [2, "trimmer", "trimming"]; let [, nameA] = robotA; > : undefined >nameA : string ->robotA : [number, string, string] +>robotA : Robot let [numberB] = robotB; >numberB : number ->robotB : [number, string, string] +>robotB : Robot let [numberA2, nameA2, skillA2] = robotA; >numberA2 : number >nameA2 : string >skillA2 : string ->robotA : [number, string, string] +>robotA : Robot let [numberC2] = [3, "edging", "Trimming edges"]; >numberC2 : number @@ -58,7 +58,7 @@ let [numberC, nameC, skillC] = [3, "edging", "Trimming edges"]; let [numberA3, ...robotAInfo] = robotA; >numberA3 : number >robotAInfo : [string, string] ->robotA : [number, string, string] +>robotA : Robot if (nameA == nameA2) { >nameA == nameA2 : boolean diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern2.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern2.types index 94b0ff295a2..9027e3be196 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern2.types @@ -7,10 +7,10 @@ declare var console: { >msg : string } type MultiSkilledRobot = [string, [string, string]]; ->MultiSkilledRobot : [string, [string, string]] +>MultiSkilledRobot : MultiSkilledRobot var multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot >["mower", ["mowing", ""]] : [string, [string, string]] >"mower" : "mower" >["mowing", ""] : [string, string] @@ -18,7 +18,7 @@ var multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >"" : "" var multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; ->multiRobotB : [string, [string, string]] +>multiRobotB : MultiSkilledRobot >["trimmer", ["trimming", "edging"]] : [string, [string, string]] >"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] @@ -28,17 +28,17 @@ var multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; let [, skillA] = multiRobotA; > : undefined >skillA : [string, string] ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot let [nameMB] = multiRobotB; >nameMB : string ->multiRobotB : [string, [string, string]] +>multiRobotB : MultiSkilledRobot let [nameMA, [primarySkillA, secondarySkillA]] = multiRobotA; >nameMA : string >primarySkillA : string >secondarySkillA : string ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot let [nameMC] = ["roomba", ["vaccum", "mopping"]]; >nameMC : string @@ -60,7 +60,7 @@ let [nameMC2, [primarySkillC, secondarySkillC]] = ["roomba", ["vaccum", "mopping let [...multiRobotAInfo] = multiRobotA; >multiRobotAInfo : [string, [string, string]] ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot if (nameMB == nameMA) { >nameMB == nameMA : boolean diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern3.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern3.types index 10025aabc0a..1ee682f838a 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern3.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern3.types @@ -7,27 +7,27 @@ declare var console: { >msg : any } type Robot = [number, string, string]; ->Robot : [number, string, string] +>Robot : Robot type MultiSkilledRobot = [string, [string, string]]; ->MultiSkilledRobot : [string, [string, string]] +>MultiSkilledRobot : MultiSkilledRobot var robotA: Robot = [1, "mower", "mowing"]; ->robotA : [number, string, string] +>robotA : Robot >[1, "mower", "mowing"] : [number, string, string] >1 : 1 >"mower" : "mower" >"mowing" : "mowing" var robotB: Robot = [2, "trimmer", "trimming"]; ->robotB : [number, string, string] +>robotB : Robot >[2, "trimmer", "trimming"] : [number, string, string] >2 : 2 >"trimmer" : "trimmer" >"trimming" : "trimming" var multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot >["mower", ["mowing", ""]] : [string, [string, string]] >"mower" : "mower" >["mowing", ""] : [string, string] @@ -35,7 +35,7 @@ var multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >"" : "" var multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; ->multiRobotB : [string, [string, string]] +>multiRobotB : MultiSkilledRobot >["trimmer", ["trimming", "edging"]] : [string, [string, string]] >"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] @@ -61,19 +61,19 @@ let multiRobotAInfo: (string | [string, string])[]; >multiRobotAInfo : (string | [string, string])[] [, nameA] = robotA; ->[, nameA] = robotA : [number, string, string] +>[, nameA] = robotA : Robot >[, nameA] : [undefined, string] > : undefined >nameA : string ->robotA : [number, string, string] +>robotA : Robot [, nameB] = getRobotB(); ->[, nameB] = getRobotB() : [number, string, string] +>[, nameB] = getRobotB() : Robot >[, nameB] : [undefined, string] > : undefined >nameB : string ->getRobotB() : [number, string, string] ->getRobotB : () => [number, string, string] +>getRobotB() : Robot +>getRobotB : () => Robot [, nameB] = [2, "trimmer", "trimming"]; >[, nameB] = [2, "trimmer", "trimming"] : [number, string, string] @@ -86,19 +86,19 @@ let multiRobotAInfo: (string | [string, string])[]; >"trimming" : "trimming" [, multiSkillB] = multiRobotB; ->[, multiSkillB] = multiRobotB : [string, [string, string]] +>[, multiSkillB] = multiRobotB : MultiSkilledRobot >[, multiSkillB] : [undefined, [string, string]] > : undefined >multiSkillB : [string, string] ->multiRobotB : [string, [string, string]] +>multiRobotB : MultiSkilledRobot [, multiSkillB] = getMultiRobotB(); ->[, multiSkillB] = getMultiRobotB() : [string, [string, string]] +>[, multiSkillB] = getMultiRobotB() : MultiSkilledRobot >[, multiSkillB] : [undefined, [string, string]] > : undefined >multiSkillB : [string, string] ->getMultiRobotB() : [string, [string, string]] ->getMultiRobotB : () => [string, [string, string]] +>getMultiRobotB() : MultiSkilledRobot +>getMultiRobotB : () => MultiSkilledRobot [, multiSkillB] = ["roomba", ["vaccum", "mopping"]]; >[, multiSkillB] = ["roomba", ["vaccum", "mopping"]] : [string, [string, string]] @@ -112,17 +112,17 @@ let multiRobotAInfo: (string | [string, string])[]; >"mopping" : "mopping" [numberB] = robotB; ->[numberB] = robotB : [number, string, string] +>[numberB] = robotB : Robot >[numberB] : [number] >numberB : number ->robotB : [number, string, string] +>robotB : Robot [numberB] = getRobotB(); ->[numberB] = getRobotB() : [number, string, string] +>[numberB] = getRobotB() : Robot >[numberB] : [number] >numberB : number ->getRobotB() : [number, string, string] ->getRobotB : () => [number, string, string] +>getRobotB() : Robot +>getRobotB : () => Robot [numberB] = [2, "trimmer", "trimming"]; >[numberB] = [2, "trimmer", "trimming"] : [number, string, string] @@ -134,17 +134,17 @@ let multiRobotAInfo: (string | [string, string])[]; >"trimming" : "trimming" [nameMB] = multiRobotB; ->[nameMB] = multiRobotB : [string, [string, string]] +>[nameMB] = multiRobotB : MultiSkilledRobot >[nameMB] : [string] >nameMB : string ->multiRobotB : [string, [string, string]] +>multiRobotB : MultiSkilledRobot [nameMB] = getMultiRobotB(); ->[nameMB] = getMultiRobotB() : [string, [string, string]] +>[nameMB] = getMultiRobotB() : MultiSkilledRobot >[nameMB] : [string] >nameMB : string ->getMultiRobotB() : [string, [string, string]] ->getMultiRobotB : () => [string, [string, string]] +>getMultiRobotB() : MultiSkilledRobot +>getMultiRobotB : () => MultiSkilledRobot [nameMB] = ["trimmer", ["trimming", "edging"]]; >[nameMB] = ["trimmer", ["trimming", "edging"]] : [string, string[]] @@ -157,21 +157,21 @@ let multiRobotAInfo: (string | [string, string])[]; >"edging" : "edging" [numberB, nameB, skillB] = robotB; ->[numberB, nameB, skillB] = robotB : [number, string, string] +>[numberB, nameB, skillB] = robotB : Robot >[numberB, nameB, skillB] : [number, string, string] >numberB : number >nameB : string >skillB : string ->robotB : [number, string, string] +>robotB : Robot [numberB, nameB, skillB] = getRobotB(); ->[numberB, nameB, skillB] = getRobotB() : [number, string, string] +>[numberB, nameB, skillB] = getRobotB() : Robot >[numberB, nameB, skillB] : [number, string, string] >numberB : number >nameB : string >skillB : string ->getRobotB() : [number, string, string] ->getRobotB : () => [number, string, string] +>getRobotB() : Robot +>getRobotB : () => Robot [numberB, nameB, skillB] = [2, "trimmer", "trimming"]; >[numberB, nameB, skillB] = [2, "trimmer", "trimming"] : [number, string, string] @@ -185,23 +185,23 @@ let multiRobotAInfo: (string | [string, string])[]; >"trimming" : "trimming" [nameMB, [primarySkillB, secondarySkillB]] = multiRobotB; ->[nameMB, [primarySkillB, secondarySkillB]] = multiRobotB : [string, [string, string]] +>[nameMB, [primarySkillB, secondarySkillB]] = multiRobotB : MultiSkilledRobot >[nameMB, [primarySkillB, secondarySkillB]] : [string, [string, string]] >nameMB : string >[primarySkillB, secondarySkillB] : [string, string] >primarySkillB : string >secondarySkillB : string ->multiRobotB : [string, [string, string]] +>multiRobotB : MultiSkilledRobot [nameMB, [primarySkillB, secondarySkillB]] = getMultiRobotB(); ->[nameMB, [primarySkillB, secondarySkillB]] = getMultiRobotB() : [string, [string, string]] +>[nameMB, [primarySkillB, secondarySkillB]] = getMultiRobotB() : MultiSkilledRobot >[nameMB, [primarySkillB, secondarySkillB]] : [string, [string, string]] >nameMB : string >[primarySkillB, secondarySkillB] : [string, string] >primarySkillB : string >secondarySkillB : string ->getMultiRobotB() : [string, [string, string]] ->getMultiRobotB : () => [string, [string, string]] +>getMultiRobotB() : MultiSkilledRobot +>getMultiRobotB : () => MultiSkilledRobot [nameMB, [primarySkillB, secondarySkillB]] = ["trimmer", ["trimming", "edging"]]; >[nameMB, [primarySkillB, secondarySkillB]] = ["trimmer", ["trimming", "edging"]] : [string, [string, string]] @@ -217,48 +217,48 @@ let multiRobotAInfo: (string | [string, string])[]; >"edging" : "edging" [numberB, ...robotAInfo] = robotB; ->[numberB, ...robotAInfo] = robotB : [number, string, string] +>[numberB, ...robotAInfo] = robotB : Robot >[numberB, ...robotAInfo] : [number, ...(string | number)[]] >numberB : number >...robotAInfo : string | number >robotAInfo : (string | number)[] ->robotB : [number, string, string] +>robotB : Robot [numberB, ...robotAInfo] = getRobotB(); ->[numberB, ...robotAInfo] = getRobotB() : [number, string, string] +>[numberB, ...robotAInfo] = getRobotB() : Robot >[numberB, ...robotAInfo] : [number, ...(string | number)[]] >numberB : number >...robotAInfo : string | number >robotAInfo : (string | number)[] ->getRobotB() : [number, string, string] ->getRobotB : () => [number, string, string] +>getRobotB() : Robot +>getRobotB : () => Robot [numberB, ...robotAInfo] = [2, "trimmer", "trimming"]; ->[numberB, ...robotAInfo] = [2, "trimmer", "trimming"] : [number, string, string] +>[numberB, ...robotAInfo] = [2, "trimmer", "trimming"] : Robot >[numberB, ...robotAInfo] : [number, ...(string | number)[]] >numberB : number >...robotAInfo : string | number >robotAInfo : (string | number)[] ->[2, "trimmer", "trimming"] : [number, string, string] +>[2, "trimmer", "trimming"] : Robot >[2, "trimmer", "trimming"] : [number, string, string] >2 : 2 >"trimmer" : "trimmer" >"trimming" : "trimming" [...multiRobotAInfo] = multiRobotA; ->[...multiRobotAInfo] = multiRobotA : [string, [string, string]] +>[...multiRobotAInfo] = multiRobotA : MultiSkilledRobot >[...multiRobotAInfo] : (string | [string, string])[] >...multiRobotAInfo : string | [string, string] >multiRobotAInfo : (string | [string, string])[] ->multiRobotA : [string, [string, string]] +>multiRobotA : MultiSkilledRobot [...multiRobotAInfo] = getMultiRobotB(); ->[...multiRobotAInfo] = getMultiRobotB() : [string, [string, string]] +>[...multiRobotAInfo] = getMultiRobotB() : MultiSkilledRobot >[...multiRobotAInfo] : (string | [string, string])[] >...multiRobotAInfo : string | [string, string] >multiRobotAInfo : (string | [string, string])[] ->getMultiRobotB() : [string, [string, string]] ->getMultiRobotB : () => [string, [string, string]] +>getMultiRobotB() : MultiSkilledRobot +>getMultiRobotB : () => MultiSkilledRobot [...multiRobotAInfo] = ["trimmer", ["trimming", "edging"]]; >[...multiRobotAInfo] = ["trimmer", ["trimming", "edging"]] : (string | [string, string])[] @@ -285,15 +285,15 @@ if (nameA == nameB) { } function getRobotB() { ->getRobotB : () => [number, string, string] +>getRobotB : () => Robot return robotB; ->robotB : [number, string, string] +>robotB : Robot } function getMultiRobotB() { ->getMultiRobotB : () => [string, [string, string]] +>getMultiRobotB : () => MultiSkilledRobot return multiRobotB; ->multiRobotB : [string, [string, string]] +>multiRobotB : MultiSkilledRobot } diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues.types index 7e4ae19d394..0bdf495f09e 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues.types @@ -7,17 +7,17 @@ declare var console: { >msg : string } type Robot = [number, string, string]; ->Robot : [number, string, string] +>Robot : Robot var robotA: Robot = [1, "mower", "mowing"]; ->robotA : [number, string, string] +>robotA : Robot >[1, "mower", "mowing"] : [number, string, string] >1 : 1 >"mower" : "mower" >"mowing" : "mowing" var robotB: Robot = [2, "trimmer", "trimming"]; ->robotB : [number, string, string] +>robotB : Robot >[2, "trimmer", "trimming"] : [number, string, string] >2 : 2 >"trimmer" : "trimmer" @@ -27,13 +27,13 @@ let [, nameA = "noName"] = robotA; > : undefined >nameA : string >"noName" : "noName" ->robotA : [number, string, string] +>robotA : Robot let [numberB = -1] = robotB; >numberB : number >-1 : -1 >1 : 1 ->robotB : [number, string, string] +>robotB : Robot let [numberA2 = -1, nameA2 = "noName", skillA2 = "noSkill"] = robotA; >numberA2 : number @@ -43,7 +43,7 @@ let [numberA2 = -1, nameA2 = "noName", skillA2 = "noSkill"] = robotA; >"noName" : "noName" >skillA2 : string >"noSkill" : "noSkill" ->robotA : [number, string, string] +>robotA : Robot let [numberC2 = -1] = [3, "edging", "Trimming edges"]; >numberC2 : number @@ -72,7 +72,7 @@ let [numberA3 = -1, ...robotAInfo] = robotA; >-1 : -1 >1 : 1 >robotAInfo : [string, string] ->robotA : [number, string, string] +>robotA : Robot if (nameA == nameA2) { >nameA == nameA2 : boolean diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.types index 3781d10d069..44fbba0b1ad 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.types @@ -7,10 +7,10 @@ declare var console: { >msg : string } type MultiSkilledRobot = [string, string[]]; ->MultiSkilledRobot : [string, string[]] +>MultiSkilledRobot : MultiSkilledRobot var multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; ->multiRobotA : [string, string[]] +>multiRobotA : MultiSkilledRobot >["mower", ["mowing", ""]] : [string, string[]] >"mower" : "mower" >["mowing", ""] : string[] @@ -18,7 +18,7 @@ var multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >"" : "" var multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; ->multiRobotB : [string, string[]] +>multiRobotB : MultiSkilledRobot >["trimmer", ["trimming", "edging"]] : [string, string[]] >"trimmer" : "trimmer" >["trimming", "edging"] : string[] @@ -31,12 +31,12 @@ let [, skillA = ["noSkill", "noSkill"]] = multiRobotA; >["noSkill", "noSkill"] : string[] >"noSkill" : "noSkill" >"noSkill" : "noSkill" ->multiRobotA : [string, string[]] +>multiRobotA : MultiSkilledRobot let [nameMB = "noName" ] = multiRobotB; >nameMB : string >"noName" : "noName" ->multiRobotB : [string, string[]] +>multiRobotB : MultiSkilledRobot let [nameMA = "noName", [primarySkillA = "noSkill", secondarySkillA = "noSkill"] = ["noSkill", "noSkill"]] = multiRobotA; >nameMA : string @@ -48,7 +48,7 @@ let [nameMA = "noName", [primarySkillA = "noSkill", secondarySkillA = "noSkill"] >["noSkill", "noSkill"] : [string, string] >"noSkill" : "noSkill" >"noSkill" : "noSkill" ->multiRobotA : [string, string[]] +>multiRobotA : MultiSkilledRobot let [nameMC = "noName" ] = ["roomba", ["vaccum", "mopping"]]; >nameMC : string diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues3.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues3.types index 2f9d1dac6e3..8968f49732e 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues3.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues3.types @@ -7,27 +7,27 @@ declare var console: { >msg : any } type Robot = [number, string, string]; ->Robot : [number, string, string] +>Robot : Robot type MultiSkilledRobot = [string, string[]]; ->MultiSkilledRobot : [string, string[]] +>MultiSkilledRobot : MultiSkilledRobot var robotA: Robot = [1, "mower", "mowing"]; ->robotA : [number, string, string] +>robotA : Robot >[1, "mower", "mowing"] : [number, string, string] >1 : 1 >"mower" : "mower" >"mowing" : "mowing" var robotB: Robot = [2, "trimmer", "trimming"]; ->robotB : [number, string, string] +>robotB : Robot >[2, "trimmer", "trimming"] : [number, string, string] >2 : 2 >"trimmer" : "trimmer" >"trimming" : "trimming" var multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; ->multiRobotA : [string, string[]] +>multiRobotA : MultiSkilledRobot >["mower", ["mowing", ""]] : [string, string[]] >"mower" : "mower" >["mowing", ""] : string[] @@ -35,7 +35,7 @@ var multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >"" : "" var multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; ->multiRobotB : [string, string[]] +>multiRobotB : MultiSkilledRobot >["trimmer", ["trimming", "edging"]] : [string, string[]] >"trimmer" : "trimmer" >["trimming", "edging"] : string[] @@ -61,23 +61,23 @@ let multiRobotAInfo: (string | string[])[]; >multiRobotAInfo : (string | string[])[] [, nameA = "helloNoName"] = robotA; ->[, nameA = "helloNoName"] = robotA : [number, string, string] +>[, nameA = "helloNoName"] = robotA : Robot >[, nameA = "helloNoName"] : [undefined, string] > : undefined >nameA = "helloNoName" : "helloNoName" >nameA : string >"helloNoName" : "helloNoName" ->robotA : [number, string, string] +>robotA : Robot [, nameB = "helloNoName"] = getRobotB(); ->[, nameB = "helloNoName"] = getRobotB() : [number, string, string] +>[, nameB = "helloNoName"] = getRobotB() : Robot >[, nameB = "helloNoName"] : [undefined, string] > : undefined >nameB = "helloNoName" : "helloNoName" >nameB : string >"helloNoName" : "helloNoName" ->getRobotB() : [number, string, string] ->getRobotB : () => [number, string, string] +>getRobotB() : Robot +>getRobotB : () => Robot [, nameB = "helloNoName"] = [2, "trimmer", "trimming"]; >[, nameB = "helloNoName"] = [2, "trimmer", "trimming"] : [number, string, string] @@ -92,23 +92,23 @@ let multiRobotAInfo: (string | string[])[]; >"trimming" : "trimming" [, multiSkillB = []] = multiRobotB; ->[, multiSkillB = []] = multiRobotB : [string, string[]] +>[, multiSkillB = []] = multiRobotB : MultiSkilledRobot >[, multiSkillB = []] : [undefined, undefined[]] > : undefined >multiSkillB = [] : undefined[] >multiSkillB : string[] >[] : undefined[] ->multiRobotB : [string, string[]] +>multiRobotB : MultiSkilledRobot [, multiSkillB = []] = getMultiRobotB(); ->[, multiSkillB = []] = getMultiRobotB() : [string, string[]] +>[, multiSkillB = []] = getMultiRobotB() : MultiSkilledRobot >[, multiSkillB = []] : [undefined, undefined[]] > : undefined >multiSkillB = [] : undefined[] >multiSkillB : string[] >[] : undefined[] ->getMultiRobotB() : [string, string[]] ->getMultiRobotB : () => [string, string[]] +>getMultiRobotB() : MultiSkilledRobot +>getMultiRobotB : () => MultiSkilledRobot [, multiSkillB = []] = ["roomba", ["vaccum", "mopping"]]; >[, multiSkillB = []] = ["roomba", ["vaccum", "mopping"]] : [string, string[]] @@ -124,23 +124,23 @@ let multiRobotAInfo: (string | string[])[]; >"mopping" : "mopping" [numberB = -1] = robotB; ->[numberB = -1] = robotB : [number, string, string] +>[numberB = -1] = robotB : Robot >[numberB = -1] : [number] >numberB = -1 : -1 >numberB : number >-1 : -1 >1 : 1 ->robotB : [number, string, string] +>robotB : Robot [numberB = -1] = getRobotB(); ->[numberB = -1] = getRobotB() : [number, string, string] +>[numberB = -1] = getRobotB() : Robot >[numberB = -1] : [number] >numberB = -1 : -1 >numberB : number >-1 : -1 >1 : 1 ->getRobotB() : [number, string, string] ->getRobotB : () => [number, string, string] +>getRobotB() : Robot +>getRobotB : () => Robot [numberB = -1] = [2, "trimmer", "trimming"]; >[numberB = -1] = [2, "trimmer", "trimming"] : [number, string, string] @@ -155,21 +155,21 @@ let multiRobotAInfo: (string | string[])[]; >"trimming" : "trimming" [nameMB = "helloNoName"] = multiRobotB; ->[nameMB = "helloNoName"] = multiRobotB : [string, string[]] +>[nameMB = "helloNoName"] = multiRobotB : MultiSkilledRobot >[nameMB = "helloNoName"] : [string] >nameMB = "helloNoName" : "helloNoName" >nameMB : string >"helloNoName" : "helloNoName" ->multiRobotB : [string, string[]] +>multiRobotB : MultiSkilledRobot [nameMB = "helloNoName"] = getMultiRobotB(); ->[nameMB = "helloNoName"] = getMultiRobotB() : [string, string[]] +>[nameMB = "helloNoName"] = getMultiRobotB() : MultiSkilledRobot >[nameMB = "helloNoName"] : [string] >nameMB = "helloNoName" : "helloNoName" >nameMB : string >"helloNoName" : "helloNoName" ->getMultiRobotB() : [string, string[]] ->getMultiRobotB : () => [string, string[]] +>getMultiRobotB() : MultiSkilledRobot +>getMultiRobotB : () => MultiSkilledRobot [nameMB = "helloNoName"] = ["trimmer", ["trimming", "edging"]]; >[nameMB = "helloNoName"] = ["trimmer", ["trimming", "edging"]] : [string, string[]] @@ -184,7 +184,7 @@ let multiRobotAInfo: (string | string[])[]; >"edging" : "edging" [numberB = -1, nameB = "helloNoName", skillB = "noSkill"] = robotB; ->[numberB = -1, nameB = "helloNoName", skillB = "noSkill"] = robotB : [number, string, string] +>[numberB = -1, nameB = "helloNoName", skillB = "noSkill"] = robotB : Robot >[numberB = -1, nameB = "helloNoName", skillB = "noSkill"] : [number, string, string] >numberB = -1 : -1 >numberB : number @@ -196,10 +196,10 @@ let multiRobotAInfo: (string | string[])[]; >skillB = "noSkill" : "noSkill" >skillB : string >"noSkill" : "noSkill" ->robotB : [number, string, string] +>robotB : Robot [numberB = -1, nameB = "helloNoName", skillB = "noSkill"] = getRobotB(); ->[numberB = -1, nameB = "helloNoName", skillB = "noSkill"] = getRobotB() : [number, string, string] +>[numberB = -1, nameB = "helloNoName", skillB = "noSkill"] = getRobotB() : Robot >[numberB = -1, nameB = "helloNoName", skillB = "noSkill"] : [number, string, string] >numberB = -1 : -1 >numberB : number @@ -211,8 +211,8 @@ let multiRobotAInfo: (string | string[])[]; >skillB = "noSkill" : "noSkill" >skillB : string >"noSkill" : "noSkill" ->getRobotB() : [number, string, string] ->getRobotB : () => [number, string, string] +>getRobotB() : Robot +>getRobotB : () => Robot [numberB = -1, nameB = "helloNoName", skillB = "noSkill"] = [2, "trimmer", "trimming"]; >[numberB = -1, nameB = "helloNoName", skillB = "noSkill"] = [2, "trimmer", "trimming"] : [number, string, string] @@ -233,7 +233,7 @@ let multiRobotAInfo: (string | string[])[]; >"trimming" : "trimming" [nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] = multiRobotB; ->[nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] = multiRobotB : [string, string[]] +>[nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] = multiRobotB : MultiSkilledRobot >[nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] : [string, []] >nameMB = "helloNoName" : "helloNoName" >nameMB : string @@ -247,10 +247,10 @@ let multiRobotAInfo: (string | string[])[]; >secondarySkillB : string >"noSkill" : "noSkill" >[] : [] ->multiRobotB : [string, string[]] +>multiRobotB : MultiSkilledRobot [nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] = getMultiRobotB(); ->[nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] = getMultiRobotB() : [string, string[]] +>[nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] = getMultiRobotB() : MultiSkilledRobot >[nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] : [string, []] >nameMB = "helloNoName" : "helloNoName" >nameMB : string @@ -264,8 +264,8 @@ let multiRobotAInfo: (string | string[])[]; >secondarySkillB : string >"noSkill" : "noSkill" >[] : [] ->getMultiRobotB() : [string, string[]] ->getMultiRobotB : () => [string, string[]] +>getMultiRobotB() : MultiSkilledRobot +>getMultiRobotB : () => MultiSkilledRobot [nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] = >[nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] = ["trimmer", ["trimming", "edging"]] : [string, [string, string]] @@ -291,7 +291,7 @@ let multiRobotAInfo: (string | string[])[]; >"edging" : "edging" [numberB = -1, ...robotAInfo] = robotB; ->[numberB = -1, ...robotAInfo] = robotB : [number, string, string] +>[numberB = -1, ...robotAInfo] = robotB : Robot >[numberB = -1, ...robotAInfo] : [number, ...(string | number)[]] >numberB = -1 : -1 >numberB : number @@ -299,10 +299,10 @@ let multiRobotAInfo: (string | string[])[]; >1 : 1 >...robotAInfo : string | number >robotAInfo : (string | number)[] ->robotB : [number, string, string] +>robotB : Robot [numberB = -1, ...robotAInfo] = getRobotB(); ->[numberB = -1, ...robotAInfo] = getRobotB() : [number, string, string] +>[numberB = -1, ...robotAInfo] = getRobotB() : Robot >[numberB = -1, ...robotAInfo] : [number, ...(string | number)[]] >numberB = -1 : -1 >numberB : number @@ -310,11 +310,11 @@ let multiRobotAInfo: (string | string[])[]; >1 : 1 >...robotAInfo : string | number >robotAInfo : (string | number)[] ->getRobotB() : [number, string, string] ->getRobotB : () => [number, string, string] +>getRobotB() : Robot +>getRobotB : () => Robot [numberB = -1, ...robotAInfo] = [2, "trimmer", "trimming"]; ->[numberB = -1, ...robotAInfo] = [2, "trimmer", "trimming"] : [number, string, string] +>[numberB = -1, ...robotAInfo] = [2, "trimmer", "trimming"] : Robot >[numberB = -1, ...robotAInfo] : [number, ...(string | number)[]] >numberB = -1 : -1 >numberB : number @@ -322,7 +322,7 @@ let multiRobotAInfo: (string | string[])[]; >1 : 1 >...robotAInfo : string | number >robotAInfo : (string | number)[] ->[2, "trimmer", "trimming"] : [number, string, string] +>[2, "trimmer", "trimming"] : Robot >[2, "trimmer", "trimming"] : [number, string, string] >2 : 2 >"trimmer" : "trimmer" @@ -342,15 +342,15 @@ if (nameA == nameB) { } function getRobotB() { ->getRobotB : () => [number, string, string] +>getRobotB : () => Robot return robotB; ->robotB : [number, string, string] +>robotB : Robot } function getMultiRobotB() { ->getMultiRobotB : () => [string, string[]] +>getMultiRobotB : () => MultiSkilledRobot return multiRobotB; ->multiRobotB : [string, string[]] +>multiRobotB : MultiSkilledRobot } diff --git a/tests/baselines/reference/specedNoStackBlown.types b/tests/baselines/reference/specedNoStackBlown.types index 654f98941df..884c24151a0 100644 --- a/tests/baselines/reference/specedNoStackBlown.types +++ b/tests/baselines/reference/specedNoStackBlown.types @@ -26,10 +26,10 @@ type ErrorMsg = >field : string export type Spec = [Predicate, ErrorMsg]; ->Spec : [Predicate, ErrorMsg] +>Spec : Spec export type SpecArray = Array>; ->SpecArray : [Predicate, ErrorMsg][] +>SpecArray : SpecArray export type SpecFunction = [INPUT] extends [ReadonlyArray] >SpecFunction : SpecFunction diff --git a/tests/baselines/reference/spreadBooleanRespectsFreshness.types b/tests/baselines/reference/spreadBooleanRespectsFreshness.types index c607422b062..cd20dc31944 100644 --- a/tests/baselines/reference/spreadBooleanRespectsFreshness.types +++ b/tests/baselines/reference/spreadBooleanRespectsFreshness.types @@ -7,7 +7,7 @@ type FooBase = string | false; >false : false type FooArray = FooBase[]; ->FooArray : FooBase[] +>FooArray : FooArray declare let foo1: Foo; >foo1 : Foo @@ -20,13 +20,13 @@ foo1 = [...Array.isArray(foo2) ? foo2 : [foo2]]; >foo1 : Foo >[...Array.isArray(foo2) ? foo2 : [foo2]] : FooBase[] >...Array.isArray(foo2) ? foo2 : [foo2] : FooBase ->Array.isArray(foo2) ? foo2 : [foo2] : FooBase[] +>Array.isArray(foo2) ? foo2 : [foo2] : FooArray >Array.isArray(foo2) : boolean >Array.isArray : (arg: any) => arg is any[] >Array : ArrayConstructor >isArray : (arg: any) => arg is any[] >foo2 : Foo ->foo2 : FooBase[] +>foo2 : FooArray >[foo2] : FooBase[] >foo2 : FooBase diff --git a/tests/baselines/reference/strictFunctionTypesErrors.errors.txt b/tests/baselines/reference/strictFunctionTypesErrors.errors.txt index 3ff04c44fb7..6f474663dcb 100644 --- a/tests/baselines/reference/strictFunctionTypesErrors.errors.txt +++ b/tests/baselines/reference/strictFunctionTypesErrors.errors.txt @@ -69,9 +69,8 @@ tests/cases/compiler/strictFunctionTypesErrors.ts(126,1): error TS2322: Type 'Cr tests/cases/compiler/strictFunctionTypesErrors.ts(127,1): error TS2322: Type 'Crate' is not assignable to type 'Crate'. Types of property 'item' are incompatible. Type 'Animal' is not assignable to type 'Dog'. -tests/cases/compiler/strictFunctionTypesErrors.ts(133,1): error TS2322: Type '(f: (x: Dog) => Dog) => void' is not assignable to type '(f: (x: Animal) => Animal) => void'. - Types of parameters 'f' and 'f' are incompatible. - Type 'Animal' is not assignable to type 'Dog'. +tests/cases/compiler/strictFunctionTypesErrors.ts(133,1): error TS2328: Types of parameters 'f' and 'f' are incompatible. + Type 'Animal' is not assignable to type 'Dog'. tests/cases/compiler/strictFunctionTypesErrors.ts(134,1): error TS2322: Type '(f: (x: Animal) => Animal) => void' is not assignable to type '(f: (x: Dog) => Dog) => void'. Types of parameters 'f' and 'f' are incompatible. Types of parameters 'x' and 'x' are incompatible. @@ -324,9 +323,8 @@ tests/cases/compiler/strictFunctionTypesErrors.ts(155,5): error TS2322: Type '(c declare let fc2: (f: (x: Dog) => Dog) => void; fc1 = fc2; // Error ~~~ -!!! error TS2322: Type '(f: (x: Dog) => Dog) => void' is not assignable to type '(f: (x: Animal) => Animal) => void'. -!!! error TS2322: Types of parameters 'f' and 'f' are incompatible. -!!! error TS2322: Type 'Animal' is not assignable to type 'Dog'. +!!! error TS2328: Types of parameters 'f' and 'f' are incompatible. +!!! error TS2328: Type 'Animal' is not assignable to type 'Dog'. fc2 = fc1; // Error ~~~ !!! error TS2322: Type '(f: (x: Animal) => Animal) => void' is not assignable to type '(f: (x: Dog) => Dog) => void'. diff --git a/tests/baselines/reference/subtypingWithCallSignaturesWithSpecializedSignatures.errors.txt b/tests/baselines/reference/subtypingWithCallSignaturesWithSpecializedSignatures.errors.txt index 7dfb078170a..b8bc5100402 100644 --- a/tests/baselines/reference/subtypingWithCallSignaturesWithSpecializedSignatures.errors.txt +++ b/tests/baselines/reference/subtypingWithCallSignaturesWithSpecializedSignatures.errors.txt @@ -1,12 +1,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithCallSignaturesWithSpecializedSignatures.ts(70,15): error TS2430: Interface 'I2' incorrectly extends interface 'Base2'. - Types of property 'a' are incompatible. - Type '(x: string) => string' is not assignable to type '{ (x: "a"): number; (x: string): number; }'. - Type 'string' is not assignable to type 'number'. + The types returned by 'a(...)' are incompatible between these types. + Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithCallSignaturesWithSpecializedSignatures.ts(76,15): error TS2430: Interface 'I3' incorrectly extends interface 'Base2'. - Types of property 'a2' are incompatible. - Type '(x: T) => string' is not assignable to type '(x: T) => T'. - Type 'string' is not assignable to type 'T'. - 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + The types returned by 'a2(...)' are incompatible between these types. + Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithCallSignaturesWithSpecializedSignatures.ts (2 errors) ==== @@ -82,9 +80,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface I2 extends Base2 { ~~ !!! error TS2430: Interface 'I2' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'a' are incompatible. -!!! error TS2430: Type '(x: string) => string' is not assignable to type '{ (x: "a"): number; (x: string): number; }'. -!!! error TS2430: Type 'string' is not assignable to type 'number'. +!!! error TS2430: The types returned by 'a(...)' are incompatible between these types. +!!! error TS2430: Type 'string' is not assignable to type 'number'. // N's a: (x: string) => string; // error because base returns non-void; } @@ -93,10 +90,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface I3 extends Base2 { ~~ !!! error TS2430: Interface 'I3' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'a2' are incompatible. -!!! error TS2430: Type '(x: T) => string' is not assignable to type '(x: T) => T'. -!!! error TS2430: Type 'string' is not assignable to type 'T'. -!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: The types returned by 'a2(...)' are incompatible between these types. +!!! error TS2430: Type 'string' is not assignable to type 'T'. +!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. // N's a2: (x: T) => string; // error because base returns non-void; } diff --git a/tests/baselines/reference/subtypingWithConstructSignaturesWithSpecializedSignatures.errors.txt b/tests/baselines/reference/subtypingWithConstructSignaturesWithSpecializedSignatures.errors.txt index 8f4a219407a..db493045f09 100644 --- a/tests/baselines/reference/subtypingWithConstructSignaturesWithSpecializedSignatures.errors.txt +++ b/tests/baselines/reference/subtypingWithConstructSignaturesWithSpecializedSignatures.errors.txt @@ -1,12 +1,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignaturesWithSpecializedSignatures.ts(70,15): error TS2430: Interface 'I2' incorrectly extends interface 'Base2'. - Types of property 'a' are incompatible. - Type 'new (x: string) => string' is not assignable to type '{ new (x: "a"): number; new (x: string): number; }'. - Type 'string' is not assignable to type 'number'. + The types returned by 'new a(...)' are incompatible between these types. + Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignaturesWithSpecializedSignatures.ts(76,15): error TS2430: Interface 'I3' incorrectly extends interface 'Base2'. - Types of property 'a2' are incompatible. - Type 'new (x: T) => string' is not assignable to type 'new (x: T) => T'. - Type 'string' is not assignable to type 'T'. - 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + The types returned by 'new a2(...)' are incompatible between these types. + Type 'string' is not assignable to type 'T'. + 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignaturesWithSpecializedSignatures.ts (2 errors) ==== @@ -82,9 +80,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface I2 extends Base2 { ~~ !!! error TS2430: Interface 'I2' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'a' are incompatible. -!!! error TS2430: Type 'new (x: string) => string' is not assignable to type '{ new (x: "a"): number; new (x: string): number; }'. -!!! error TS2430: Type 'string' is not assignable to type 'number'. +!!! error TS2430: The types returned by 'new a(...)' are incompatible between these types. +!!! error TS2430: Type 'string' is not assignable to type 'number'. // N's a: new (x: string) => string; // error because base returns non-void; } @@ -93,10 +90,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface I3 extends Base2 { ~~ !!! error TS2430: Interface 'I3' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'a2' are incompatible. -!!! error TS2430: Type 'new (x: T) => string' is not assignable to type 'new (x: T) => T'. -!!! error TS2430: Type 'string' is not assignable to type 'T'. -!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: The types returned by 'new a2(...)' are incompatible between these types. +!!! error TS2430: Type 'string' is not assignable to type 'T'. +!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. // N's a2: new (x: T) => string; // error because base returns non-void; } diff --git a/tests/baselines/reference/subtypingWithGenericCallSignaturesWithOptionalParameters.errors.txt b/tests/baselines/reference/subtypingWithGenericCallSignaturesWithOptionalParameters.errors.txt index 36380fc97f4..4e0ef2113ec 100644 --- a/tests/baselines/reference/subtypingWithGenericCallSignaturesWithOptionalParameters.errors.txt +++ b/tests/baselines/reference/subtypingWithGenericCallSignaturesWithOptionalParameters.errors.txt @@ -5,23 +5,20 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Types of property 'a3' are incompatible. Type '(x: T, y: T) => T' is not assignable to type '(x: T) => T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(100,15): error TS2430: Interface 'I1' incorrectly extends interface 'Base2'. - Types of property 'a' are incompatible. - Type '() => T' is not assignable to type '() => T'. - Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. - 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + The types returned by 'a()' are incompatible between these types. + Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(104,15): error TS2430: Interface 'I2' incorrectly extends interface 'Base2'. - Types of property 'a' are incompatible. - Type '(x?: T) => T' is not assignable to type '() => T'. - Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. - 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + The types returned by 'a(...)' are incompatible between these types. + Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(108,15): error TS2430: Interface 'I3' incorrectly extends interface 'Base2'. Types of property 'a' are incompatible. Type '(x: T) => T' is not assignable to type '() => T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(113,15): error TS2430: Interface 'I4' incorrectly extends interface 'Base2'. - Types of property 'a2' are incompatible. - Type '() => T' is not assignable to type '(x?: T) => T'. - Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. - 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + The types returned by 'a2(...)' are incompatible between these types. + Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(117,15): error TS2430: Interface 'I5' incorrectly extends interface 'Base2'. Types of property 'a2' are incompatible. Type '(x?: T) => T' is not assignable to type '(x?: T) => T'. @@ -35,10 +32,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(126,15): error TS2430: Interface 'I7' incorrectly extends interface 'Base2'. - Types of property 'a3' are incompatible. - Type '() => T' is not assignable to type '(x: T) => T'. - Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. - 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + The types returned by 'a3(...)' are incompatible between these types. + Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(130,15): error TS2430: Interface 'I8' incorrectly extends interface 'Base2'. Types of property 'a3' are incompatible. Type '(x?: T) => T' is not assignable to type '(x: T) => T'. @@ -55,10 +51,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Types of property 'a3' are incompatible. Type '(x: T, y: T) => T' is not assignable to type '(x: T) => T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(143,15): error TS2430: Interface 'I11' incorrectly extends interface 'Base2'. - Types of property 'a4' are incompatible. - Type '() => T' is not assignable to type '(x: T, y?: T) => T'. - Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. - 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + The types returned by 'a4(...)' are incompatible between these types. + Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(147,15): error TS2430: Interface 'I12' incorrectly extends interface 'Base2'. Types of property 'a4' are incompatible. Type '(x?: T, y?: T) => T' is not assignable to type '(x: T, y?: T) => T'. @@ -78,10 +73,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(160,15): error TS2430: Interface 'I15' incorrectly extends interface 'Base2'. - Types of property 'a5' are incompatible. - Type '() => T' is not assignable to type '(x?: T, y?: T) => T'. - Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. - 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + The types returned by 'a5(...)' are incompatible between these types. + Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericCallSignaturesWithOptionalParameters.ts(164,15): error TS2430: Interface 'I16' incorrectly extends interface 'Base2'. Types of property 'a5' are incompatible. Type '(x?: T, y?: T) => T' is not assignable to type '(x?: T, y?: T) => T'. @@ -219,20 +213,18 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface I1 extends Base2 { ~~ !!! error TS2430: Interface 'I1' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'a' are incompatible. -!!! error TS2430: Type '() => T' is not assignable to type '() => T'. -!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. -!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: The types returned by 'a()' are incompatible between these types. +!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a: () => T; } interface I2 extends Base2 { ~~ !!! error TS2430: Interface 'I2' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'a' are incompatible. -!!! error TS2430: Type '(x?: T) => T' is not assignable to type '() => T'. -!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. -!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: The types returned by 'a(...)' are incompatible between these types. +!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a: (x?: T) => T; } @@ -248,10 +240,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface I4 extends Base2 { ~~ !!! error TS2430: Interface 'I4' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'a2' are incompatible. -!!! error TS2430: Type '() => T' is not assignable to type '(x?: T) => T'. -!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. -!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: The types returned by 'a2(...)' are incompatible between these types. +!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: () => T; } @@ -281,10 +272,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface I7 extends Base2 { ~~ !!! error TS2430: Interface 'I7' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'a3' are incompatible. -!!! error TS2430: Type '() => T' is not assignable to type '(x: T) => T'. -!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. -!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: The types returned by 'a3(...)' are incompatible between these types. +!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a3: () => T; } @@ -322,10 +312,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface I11 extends Base2 { ~~~ !!! error TS2430: Interface 'I11' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'a4' are incompatible. -!!! error TS2430: Type '() => T' is not assignable to type '(x: T, y?: T) => T'. -!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. -!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: The types returned by 'a4(...)' are incompatible between these types. +!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a4: () => T; } @@ -366,10 +355,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface I15 extends Base2 { ~~~ !!! error TS2430: Interface 'I15' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'a5' are incompatible. -!!! error TS2430: Type '() => T' is not assignable to type '(x?: T, y?: T) => T'. -!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. -!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: The types returned by 'a5(...)' are incompatible between these types. +!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a5: () => T; } diff --git a/tests/baselines/reference/subtypingWithGenericConstructSignaturesWithOptionalParameters.errors.txt b/tests/baselines/reference/subtypingWithGenericConstructSignaturesWithOptionalParameters.errors.txt index 427c7c1f19e..7481ba54f1e 100644 --- a/tests/baselines/reference/subtypingWithGenericConstructSignaturesWithOptionalParameters.errors.txt +++ b/tests/baselines/reference/subtypingWithGenericConstructSignaturesWithOptionalParameters.errors.txt @@ -5,23 +5,20 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Types of property 'a3' are incompatible. Type 'new (x: T, y: T) => T' is not assignable to type 'new (x: T) => T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(100,15): error TS2430: Interface 'I1' incorrectly extends interface 'Base2'. - Types of property 'a' are incompatible. - Type 'new () => T' is not assignable to type 'new () => T'. - Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. - 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + The types returned by 'new a()' are incompatible between these types. + Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(104,15): error TS2430: Interface 'I2' incorrectly extends interface 'Base2'. - Types of property 'a' are incompatible. - Type 'new (x?: T) => T' is not assignable to type 'new () => T'. - Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. - 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + The types returned by 'new a(...)' are incompatible between these types. + Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(108,15): error TS2430: Interface 'I3' incorrectly extends interface 'Base2'. Types of property 'a' are incompatible. Type 'new (x: T) => T' is not assignable to type 'new () => T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(113,15): error TS2430: Interface 'I4' incorrectly extends interface 'Base2'. - Types of property 'a2' are incompatible. - Type 'new () => T' is not assignable to type 'new (x?: T) => T'. - Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. - 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + The types returned by 'new a2(...)' are incompatible between these types. + Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(117,15): error TS2430: Interface 'I5' incorrectly extends interface 'Base2'. Types of property 'a2' are incompatible. Type 'new (x?: T) => T' is not assignable to type 'new (x?: T) => T'. @@ -35,10 +32,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(126,15): error TS2430: Interface 'I7' incorrectly extends interface 'Base2'. - Types of property 'a3' are incompatible. - Type 'new () => T' is not assignable to type 'new (x: T) => T'. - Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. - 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + The types returned by 'new a3(...)' are incompatible between these types. + Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(130,15): error TS2430: Interface 'I8' incorrectly extends interface 'Base2'. Types of property 'a3' are incompatible. Type 'new (x?: T) => T' is not assignable to type 'new (x: T) => T'. @@ -55,10 +51,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Types of property 'a3' are incompatible. Type 'new (x: T, y: T) => T' is not assignable to type 'new (x: T) => T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(143,15): error TS2430: Interface 'I11' incorrectly extends interface 'Base2'. - Types of property 'a4' are incompatible. - Type 'new () => T' is not assignable to type 'new (x: T, y?: T) => T'. - Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. - 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + The types returned by 'new a4(...)' are incompatible between these types. + Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(147,15): error TS2430: Interface 'I12' incorrectly extends interface 'Base2'. Types of property 'a4' are incompatible. Type 'new (x?: T, y?: T) => T' is not assignable to type 'new (x: T, y?: T) => T'. @@ -78,10 +73,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(160,15): error TS2430: Interface 'I15' incorrectly extends interface 'Base2'. - Types of property 'a5' are incompatible. - Type 'new () => T' is not assignable to type 'new (x?: T, y?: T) => T'. - Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. - 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. + The types returned by 'new a5(...)' are incompatible between these types. + Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. + 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithGenericConstructSignaturesWithOptionalParameters.ts(164,15): error TS2430: Interface 'I16' incorrectly extends interface 'Base2'. Types of property 'a5' are incompatible. Type 'new (x?: T, y?: T) => T' is not assignable to type 'new (x?: T, y?: T) => T'. @@ -219,20 +213,18 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface I1 extends Base2 { ~~ !!! error TS2430: Interface 'I1' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'a' are incompatible. -!!! error TS2430: Type 'new () => T' is not assignable to type 'new () => T'. -!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. -!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: The types returned by 'new a()' are incompatible between these types. +!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a: new () => T; } interface I2 extends Base2 { ~~ !!! error TS2430: Interface 'I2' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'a' are incompatible. -!!! error TS2430: Type 'new (x?: T) => T' is not assignable to type 'new () => T'. -!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. -!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: The types returned by 'new a(...)' are incompatible between these types. +!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a: new (x?: T) => T; } @@ -248,10 +240,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface I4 extends Base2 { ~~ !!! error TS2430: Interface 'I4' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'a2' are incompatible. -!!! error TS2430: Type 'new () => T' is not assignable to type 'new (x?: T) => T'. -!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. -!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: The types returned by 'new a2(...)' are incompatible between these types. +!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a2: new () => T; } @@ -281,10 +272,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface I7 extends Base2 { ~~ !!! error TS2430: Interface 'I7' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'a3' are incompatible. -!!! error TS2430: Type 'new () => T' is not assignable to type 'new (x: T) => T'. -!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. -!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: The types returned by 'new a3(...)' are incompatible between these types. +!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a3: new () => T; } @@ -322,10 +312,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface I11 extends Base2 { ~~~ !!! error TS2430: Interface 'I11' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'a4' are incompatible. -!!! error TS2430: Type 'new () => T' is not assignable to type 'new (x: T, y?: T) => T'. -!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. -!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: The types returned by 'new a4(...)' are incompatible between these types. +!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a4: new () => T; } @@ -366,10 +355,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface I15 extends Base2 { ~~~ !!! error TS2430: Interface 'I15' incorrectly extends interface 'Base2'. -!!! error TS2430: Types of property 'a5' are incompatible. -!!! error TS2430: Type 'new () => T' is not assignable to type 'new (x?: T, y?: T) => T'. -!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. -!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. +!!! error TS2430: The types returned by 'new a5(...)' are incompatible between these types. +!!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. +!!! error TS2430: 'T' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'. a5: new () => T; } diff --git a/tests/baselines/reference/thisIndexOnExistingReadonlyFieldIsNotNever.types b/tests/baselines/reference/thisIndexOnExistingReadonlyFieldIsNotNever.types index 30dfd635724..8f1eff831e3 100644 --- a/tests/baselines/reference/thisIndexOnExistingReadonlyFieldIsNotNever.types +++ b/tests/baselines/reference/thisIndexOnExistingReadonlyFieldIsNotNever.types @@ -15,7 +15,7 @@ interface CoachMarkAnchorProps { >anchor : C } type AnchorType

= Component

; ->AnchorType : Component +>AnchorType : AnchorType

class CoachMarkAnchorDecorator { >CoachMarkAnchorDecorator : CoachMarkAnchorDecorator @@ -27,28 +27,28 @@ class CoachMarkAnchorDecorator { return class CoachMarkAnchor extends Component> & P, {}> { >class CoachMarkAnchor extends Component> & P, {}> { private _onAnchorRef = (anchor: AnchorType

) => { const anchorRef = this.props.anchorRef; if (anchorRef) { anchorRef(anchor); } } } : typeof CoachMarkAnchor >CoachMarkAnchor : typeof CoachMarkAnchor ->Component : Component> & P, {}> +>Component : Component> & P, {}> private _onAnchorRef = (anchor: AnchorType

) => { ->_onAnchorRef : (anchor: Component) => void ->(anchor: AnchorType

) => { const anchorRef = this.props.anchorRef; if (anchorRef) { anchorRef(anchor); } } : (anchor: Component) => void ->anchor : Component +>_onAnchorRef : (anchor: AnchorType

) => void +>(anchor: AnchorType

) => { const anchorRef = this.props.anchorRef; if (anchorRef) { anchorRef(anchor); } } : (anchor: AnchorType

) => void +>anchor : AnchorType

const anchorRef = this.props.anchorRef; ->anchorRef : (CoachMarkAnchorProps> & P)["anchorRef"] | undefined ->this.props.anchorRef : (CoachMarkAnchorProps> & P)["anchorRef"] | undefined ->this.props : Readonly<{ children?: unknown; }> & Readonly> & P> +>anchorRef : (CoachMarkAnchorProps> & P)["anchorRef"] | undefined +>this.props.anchorRef : (CoachMarkAnchorProps> & P)["anchorRef"] | undefined +>this.props : Readonly<{ children?: unknown; }> & Readonly> & P> >this : this ->props : Readonly<{ children?: unknown; }> & Readonly> & P> ->anchorRef : (CoachMarkAnchorProps> & P)["anchorRef"] | undefined +>props : Readonly<{ children?: unknown; }> & Readonly> & P> +>anchorRef : (CoachMarkAnchorProps> & P)["anchorRef"] | undefined if (anchorRef) { ->anchorRef : (CoachMarkAnchorProps> & P)["anchorRef"] | undefined +>anchorRef : (CoachMarkAnchorProps> & P)["anchorRef"] | undefined anchorRef(anchor); >anchorRef(anchor) : void ->anchorRef : (anchor: Component) => void ->anchor : Component +>anchorRef : (anchor: AnchorType

) => void +>anchor : AnchorType

} } }; diff --git a/tests/baselines/reference/transformNestedGeneratorsWithTry.types b/tests/baselines/reference/transformNestedGeneratorsWithTry.types index 0ea963bbe4a..061342eaf44 100644 --- a/tests/baselines/reference/transformNestedGeneratorsWithTry.types +++ b/tests/baselines/reference/transformNestedGeneratorsWithTry.types @@ -4,13 +4,13 @@ import * as Bluebird from 'bluebird'; >Bluebird : PromiseConstructor async function a(): Bluebird { ->a : () => Promise +>a : () => Bluebird try { const b = async function b(): Bluebird { ->b : () => Promise ->async function b(): Bluebird { try { await Bluebird.resolve(); // -- remove this and it compiles } catch (error) { } } : () => Promise ->b : () => Promise +>b : () => Bluebird +>async function b(): Bluebird { try { await Bluebird.resolve(); // -- remove this and it compiles } catch (error) { } } : () => Bluebird +>b : () => Bluebird try { await Bluebird.resolve(); // -- remove this and it compiles @@ -27,8 +27,8 @@ async function a(): Bluebird { await b(); // -- or remove this and it compiles >await b() : void ->b() : Promise ->b : () => Promise +>b() : Bluebird +>b : () => Bluebird } catch (error) { } >error : any @@ -39,12 +39,12 @@ declare module "bluebird" { >"bluebird" : typeof import("bluebird") type Bluebird = Promise; ->Bluebird : Promise +>Bluebird : Bluebird const Bluebird: typeof Promise; >Bluebird : PromiseConstructor >Promise : PromiseConstructor export = Bluebird; ->Bluebird : Promise +>Bluebird : Bluebird } diff --git a/tests/baselines/reference/truthinessCallExpressionCoercion.errors.txt b/tests/baselines/reference/truthinessCallExpressionCoercion.errors.txt new file mode 100644 index 00000000000..1599a70db4e --- /dev/null +++ b/tests/baselines/reference/truthinessCallExpressionCoercion.errors.txt @@ -0,0 +1,91 @@ +tests/cases/compiler/truthinessCallExpressionCoercion.ts(2,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion.ts(18,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion.ts(36,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion.ts(50,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? +tests/cases/compiler/truthinessCallExpressionCoercion.ts(66,13): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? + + +==== tests/cases/compiler/truthinessCallExpressionCoercion.ts (5 errors) ==== + function onlyErrorsWhenTestingNonNullableFunctionType(required: () => boolean, optional?: () => boolean) { + if (required) { // error + ~~~~~~~~ +!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? + } + + if (optional) { // ok + } + + if (!!required) { // ok + } + + if (required()) { // ok + } + } + + function onlyErrorsWhenUnusedInBody() { + function test() { return Math.random() > 0.5; } + + if (test) { // error + ~~~~ +!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? + console.log('test'); + } + + if (test) { // ok + console.log(test); + } + + if (test) { // ok + test(); + } + + if (test) { // ok + [() => null].forEach(() => { + test(); + }); + } + + if (test) { // error + ~~~~ +!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? + [() => null].forEach(test => { + test(); + }); + } + } + + function checksPropertyAccess() { + const x = { + foo: { + bar() { return true; } + } + } + + if (x.foo.bar) { // error + ~~~~~~~~~ +!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? + } + + if (x.foo.bar) { // ok + x.foo.bar; + } + } + + class Foo { + maybeIsUser?: () => boolean; + + isUser() { + return true; + } + + test() { + if (this.isUser) { // error + ~~~~~~~~~~~ +!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? + } + + if (this.maybeIsUser) { // ok + } + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/truthinessCallExpressionCoercion.js b/tests/baselines/reference/truthinessCallExpressionCoercion.js new file mode 100644 index 00000000000..19ab1722c81 --- /dev/null +++ b/tests/baselines/reference/truthinessCallExpressionCoercion.js @@ -0,0 +1,134 @@ +//// [truthinessCallExpressionCoercion.ts] +function onlyErrorsWhenTestingNonNullableFunctionType(required: () => boolean, optional?: () => boolean) { + if (required) { // error + } + + if (optional) { // ok + } + + if (!!required) { // ok + } + + if (required()) { // ok + } +} + +function onlyErrorsWhenUnusedInBody() { + function test() { return Math.random() > 0.5; } + + if (test) { // error + console.log('test'); + } + + if (test) { // ok + console.log(test); + } + + if (test) { // ok + test(); + } + + if (test) { // ok + [() => null].forEach(() => { + test(); + }); + } + + if (test) { // error + [() => null].forEach(test => { + test(); + }); + } +} + +function checksPropertyAccess() { + const x = { + foo: { + bar() { return true; } + } + } + + if (x.foo.bar) { // error + } + + if (x.foo.bar) { // ok + x.foo.bar; + } +} + +class Foo { + maybeIsUser?: () => boolean; + + isUser() { + return true; + } + + test() { + if (this.isUser) { // error + } + + if (this.maybeIsUser) { // ok + } + } +} + + +//// [truthinessCallExpressionCoercion.js] +function onlyErrorsWhenTestingNonNullableFunctionType(required, optional) { + if (required) { // error + } + if (optional) { // ok + } + if (!!required) { // ok + } + if (required()) { // ok + } +} +function onlyErrorsWhenUnusedInBody() { + function test() { return Math.random() > 0.5; } + if (test) { // error + console.log('test'); + } + if (test) { // ok + console.log(test); + } + if (test) { // ok + test(); + } + if (test) { // ok + [function () { return null; }].forEach(function () { + test(); + }); + } + if (test) { // error + [function () { return null; }].forEach(function (test) { + test(); + }); + } +} +function checksPropertyAccess() { + var x = { + foo: { + bar: function () { return true; } + } + }; + if (x.foo.bar) { // error + } + if (x.foo.bar) { // ok + x.foo.bar; + } +} +var Foo = /** @class */ (function () { + function Foo() { + } + Foo.prototype.isUser = function () { + return true; + }; + Foo.prototype.test = function () { + if (this.isUser) { // error + } + if (this.maybeIsUser) { // ok + } + }; + return Foo; +}()); diff --git a/tests/baselines/reference/truthinessCallExpressionCoercion.symbols b/tests/baselines/reference/truthinessCallExpressionCoercion.symbols new file mode 100644 index 00000000000..cbfe456a82c --- /dev/null +++ b/tests/baselines/reference/truthinessCallExpressionCoercion.symbols @@ -0,0 +1,153 @@ +=== tests/cases/compiler/truthinessCallExpressionCoercion.ts === +function onlyErrorsWhenTestingNonNullableFunctionType(required: () => boolean, optional?: () => boolean) { +>onlyErrorsWhenTestingNonNullableFunctionType : Symbol(onlyErrorsWhenTestingNonNullableFunctionType, Decl(truthinessCallExpressionCoercion.ts, 0, 0)) +>required : Symbol(required, Decl(truthinessCallExpressionCoercion.ts, 0, 54)) +>optional : Symbol(optional, Decl(truthinessCallExpressionCoercion.ts, 0, 78)) + + if (required) { // error +>required : Symbol(required, Decl(truthinessCallExpressionCoercion.ts, 0, 54)) + } + + if (optional) { // ok +>optional : Symbol(optional, Decl(truthinessCallExpressionCoercion.ts, 0, 78)) + } + + if (!!required) { // ok +>required : Symbol(required, Decl(truthinessCallExpressionCoercion.ts, 0, 54)) + } + + if (required()) { // ok +>required : Symbol(required, Decl(truthinessCallExpressionCoercion.ts, 0, 54)) + } +} + +function onlyErrorsWhenUnusedInBody() { +>onlyErrorsWhenUnusedInBody : Symbol(onlyErrorsWhenUnusedInBody, Decl(truthinessCallExpressionCoercion.ts, 12, 1)) + + function test() { return Math.random() > 0.5; } +>test : Symbol(test, Decl(truthinessCallExpressionCoercion.ts, 14, 39)) +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) + + if (test) { // error +>test : Symbol(test, Decl(truthinessCallExpressionCoercion.ts, 14, 39)) + + console.log('test'); +>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, --, --)) + } + + if (test) { // ok +>test : Symbol(test, Decl(truthinessCallExpressionCoercion.ts, 14, 39)) + + console.log(test); +>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, --, --)) +>test : Symbol(test, Decl(truthinessCallExpressionCoercion.ts, 14, 39)) + } + + if (test) { // ok +>test : Symbol(test, Decl(truthinessCallExpressionCoercion.ts, 14, 39)) + + test(); +>test : Symbol(test, Decl(truthinessCallExpressionCoercion.ts, 14, 39)) + } + + if (test) { // ok +>test : Symbol(test, Decl(truthinessCallExpressionCoercion.ts, 14, 39)) + + [() => null].forEach(() => { +>[() => null].forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) + + test(); +>test : Symbol(test, Decl(truthinessCallExpressionCoercion.ts, 14, 39)) + + }); + } + + if (test) { // error +>test : Symbol(test, Decl(truthinessCallExpressionCoercion.ts, 14, 39)) + + [() => null].forEach(test => { +>[() => null].forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>test : Symbol(test, Decl(truthinessCallExpressionCoercion.ts, 36, 29)) + + test(); +>test : Symbol(test, Decl(truthinessCallExpressionCoercion.ts, 36, 29)) + + }); + } +} + +function checksPropertyAccess() { +>checksPropertyAccess : Symbol(checksPropertyAccess, Decl(truthinessCallExpressionCoercion.ts, 40, 1)) + + const x = { +>x : Symbol(x, Decl(truthinessCallExpressionCoercion.ts, 43, 9)) + + foo: { +>foo : Symbol(foo, Decl(truthinessCallExpressionCoercion.ts, 43, 15)) + + bar() { return true; } +>bar : Symbol(bar, Decl(truthinessCallExpressionCoercion.ts, 44, 14)) + } + } + + if (x.foo.bar) { // error +>x.foo.bar : Symbol(bar, Decl(truthinessCallExpressionCoercion.ts, 44, 14)) +>x.foo : Symbol(foo, Decl(truthinessCallExpressionCoercion.ts, 43, 15)) +>x : Symbol(x, Decl(truthinessCallExpressionCoercion.ts, 43, 9)) +>foo : Symbol(foo, Decl(truthinessCallExpressionCoercion.ts, 43, 15)) +>bar : Symbol(bar, Decl(truthinessCallExpressionCoercion.ts, 44, 14)) + } + + if (x.foo.bar) { // ok +>x.foo.bar : Symbol(bar, Decl(truthinessCallExpressionCoercion.ts, 44, 14)) +>x.foo : Symbol(foo, Decl(truthinessCallExpressionCoercion.ts, 43, 15)) +>x : Symbol(x, Decl(truthinessCallExpressionCoercion.ts, 43, 9)) +>foo : Symbol(foo, Decl(truthinessCallExpressionCoercion.ts, 43, 15)) +>bar : Symbol(bar, Decl(truthinessCallExpressionCoercion.ts, 44, 14)) + + x.foo.bar; +>x.foo.bar : Symbol(bar, Decl(truthinessCallExpressionCoercion.ts, 44, 14)) +>x.foo : Symbol(foo, Decl(truthinessCallExpressionCoercion.ts, 43, 15)) +>x : Symbol(x, Decl(truthinessCallExpressionCoercion.ts, 43, 9)) +>foo : Symbol(foo, Decl(truthinessCallExpressionCoercion.ts, 43, 15)) +>bar : Symbol(bar, Decl(truthinessCallExpressionCoercion.ts, 44, 14)) + } +} + +class Foo { +>Foo : Symbol(Foo, Decl(truthinessCallExpressionCoercion.ts, 55, 1)) + + maybeIsUser?: () => boolean; +>maybeIsUser : Symbol(Foo.maybeIsUser, Decl(truthinessCallExpressionCoercion.ts, 57, 11)) + + isUser() { +>isUser : Symbol(Foo.isUser, Decl(truthinessCallExpressionCoercion.ts, 58, 32)) + + return true; + } + + test() { +>test : Symbol(Foo.test, Decl(truthinessCallExpressionCoercion.ts, 62, 5)) + + if (this.isUser) { // error +>this.isUser : Symbol(Foo.isUser, Decl(truthinessCallExpressionCoercion.ts, 58, 32)) +>this : Symbol(Foo, Decl(truthinessCallExpressionCoercion.ts, 55, 1)) +>isUser : Symbol(Foo.isUser, Decl(truthinessCallExpressionCoercion.ts, 58, 32)) + } + + if (this.maybeIsUser) { // ok +>this.maybeIsUser : Symbol(Foo.maybeIsUser, Decl(truthinessCallExpressionCoercion.ts, 57, 11)) +>this : Symbol(Foo, Decl(truthinessCallExpressionCoercion.ts, 55, 1)) +>maybeIsUser : Symbol(Foo.maybeIsUser, Decl(truthinessCallExpressionCoercion.ts, 57, 11)) + } + } +} + diff --git a/tests/baselines/reference/truthinessCallExpressionCoercion.types b/tests/baselines/reference/truthinessCallExpressionCoercion.types new file mode 100644 index 00000000000..1cbb89c14a3 --- /dev/null +++ b/tests/baselines/reference/truthinessCallExpressionCoercion.types @@ -0,0 +1,179 @@ +=== tests/cases/compiler/truthinessCallExpressionCoercion.ts === +function onlyErrorsWhenTestingNonNullableFunctionType(required: () => boolean, optional?: () => boolean) { +>onlyErrorsWhenTestingNonNullableFunctionType : (required: () => boolean, optional?: (() => boolean) | undefined) => void +>required : () => boolean +>optional : (() => boolean) | undefined + + if (required) { // error +>required : () => boolean + } + + if (optional) { // ok +>optional : (() => boolean) | undefined + } + + if (!!required) { // ok +>!!required : true +>!required : false +>required : () => boolean + } + + if (required()) { // ok +>required() : boolean +>required : () => boolean + } +} + +function onlyErrorsWhenUnusedInBody() { +>onlyErrorsWhenUnusedInBody : () => void + + function test() { return Math.random() > 0.5; } +>test : () => boolean +>Math.random() > 0.5 : boolean +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>0.5 : 0.5 + + if (test) { // error +>test : () => boolean + + console.log('test'); +>console.log('test') : void +>console.log : (message?: any, ...optionalParams: any[]) => void +>console : Console +>log : (message?: any, ...optionalParams: any[]) => void +>'test' : "test" + } + + if (test) { // ok +>test : () => boolean + + console.log(test); +>console.log(test) : void +>console.log : (message?: any, ...optionalParams: any[]) => void +>console : Console +>log : (message?: any, ...optionalParams: any[]) => void +>test : () => boolean + } + + if (test) { // ok +>test : () => boolean + + test(); +>test() : boolean +>test : () => boolean + } + + if (test) { // ok +>test : () => boolean + + [() => null].forEach(() => { +>[() => null].forEach(() => { test(); }) : void +>[() => null].forEach : (callbackfn: (value: () => null, index: number, array: (() => null)[]) => void, thisArg?: any) => void +>[() => null] : (() => null)[] +>() => null : () => null +>null : null +>forEach : (callbackfn: (value: () => null, index: number, array: (() => null)[]) => void, thisArg?: any) => void +>() => { test(); } : () => void + + test(); +>test() : boolean +>test : () => boolean + + }); + } + + if (test) { // error +>test : () => boolean + + [() => null].forEach(test => { +>[() => null].forEach(test => { test(); }) : void +>[() => null].forEach : (callbackfn: (value: () => null, index: number, array: (() => null)[]) => void, thisArg?: any) => void +>[() => null] : (() => null)[] +>() => null : () => null +>null : null +>forEach : (callbackfn: (value: () => null, index: number, array: (() => null)[]) => void, thisArg?: any) => void +>test => { test(); } : (test: () => null) => void +>test : () => null + + test(); +>test() : null +>test : () => null + + }); + } +} + +function checksPropertyAccess() { +>checksPropertyAccess : () => void + + const x = { +>x : { foo: { bar(): boolean; }; } +>{ foo: { bar() { return true; } } } : { foo: { bar(): boolean; }; } + + foo: { +>foo : { bar(): boolean; } +>{ bar() { return true; } } : { bar(): boolean; } + + bar() { return true; } +>bar : () => boolean +>true : true + } + } + + if (x.foo.bar) { // error +>x.foo.bar : () => boolean +>x.foo : { bar(): boolean; } +>x : { foo: { bar(): boolean; }; } +>foo : { bar(): boolean; } +>bar : () => boolean + } + + if (x.foo.bar) { // ok +>x.foo.bar : () => boolean +>x.foo : { bar(): boolean; } +>x : { foo: { bar(): boolean; }; } +>foo : { bar(): boolean; } +>bar : () => boolean + + x.foo.bar; +>x.foo.bar : () => boolean +>x.foo : { bar(): boolean; } +>x : { foo: { bar(): boolean; }; } +>foo : { bar(): boolean; } +>bar : () => boolean + } +} + +class Foo { +>Foo : Foo + + maybeIsUser?: () => boolean; +>maybeIsUser : (() => boolean) | undefined + + isUser() { +>isUser : () => boolean + + return true; +>true : true + } + + test() { +>test : () => void + + if (this.isUser) { // error +>this.isUser : () => boolean +>this : this +>isUser : () => boolean + } + + if (this.maybeIsUser) { // ok +>this.maybeIsUser : (() => boolean) | undefined +>this : this +>maybeIsUser : (() => boolean) | undefined + } + } +} + diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/modules-and-globals-mixed-in-amd.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/modules-and-globals-mixed-in-amd.js index 87ace04e448..156e26088e0 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/modules-and-globals-mixed-in-amd.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/modules-and-globals-mixed-in-amd.js @@ -1,3 +1,22 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/app --verbose +12:04:00 AM - Projects in this build: + * src/lib/tsconfig.json + * src/app/tsconfig.json + +12:04:00 AM - Project 'src/lib/tsconfig.json' is out of date because oldest output 'src/lib/module.js' is older than newest input 'src/lib/file1.ts' + +12:04:00 AM - Building project '/src/lib/tsconfig.json'... + +12:04:00 AM - Project 'src/app/tsconfig.json' is out of date because output of its dependency 'src/lib' has changed + +12:04:00 AM - Updating output of project '/src/app/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/app/tsconfig.json'... + +exitCode:: 0 + + //// [/src/app/module.js] var myGlob = 20; define("file1", ["require", "exports"], function (require, exports) { diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/multiple-emitHelpers-in-all-projects.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/multiple-emitHelpers-in-all-projects.js index 2b4e0a0a838..e09e87242a1 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/multiple-emitHelpers-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/multiple-emitHelpers-in-all-projects.js @@ -1,3 +1,22 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/app --verbose +12:04:00 AM - Projects in this build: + * src/lib/tsconfig.json + * src/app/tsconfig.json + +12:04:00 AM - Project 'src/lib/tsconfig.json' is out of date because oldest output 'src/lib/module.js' is older than newest input 'src/lib/file1.ts' + +12:04:00 AM - Building project '/src/lib/tsconfig.json'... + +12:04:00 AM - Project 'src/app/tsconfig.json' is out of date because output of its dependency 'src/lib' has changed + +12:04:00 AM - Updating output of project '/src/app/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/app/tsconfig.json'... + +exitCode:: 0 + + //// [/src/app/module.js] var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/multiple-prologues-in-all-projects.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/multiple-prologues-in-all-projects.js index f7252e6dcbc..93a7cbf7326 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/multiple-prologues-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/multiple-prologues-in-all-projects.js @@ -1,3 +1,22 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/app --verbose +12:04:00 AM - Projects in this build: + * src/lib/tsconfig.json + * src/app/tsconfig.json + +12:04:00 AM - Project 'src/lib/tsconfig.json' is out of date because oldest output 'src/lib/module.js' is older than newest input 'src/lib/file1.ts' + +12:04:00 AM - Building project '/src/lib/tsconfig.json'... + +12:04:00 AM - Project 'src/app/tsconfig.json' is out of date because output of its dependency 'src/lib' has changed + +12:04:00 AM - Updating output of project '/src/app/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/app/tsconfig.json'... + +exitCode:: 0 + + //// [/src/app/module.js] "use strict"; "myPrologue"; diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/shebang-in-all-projects.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/shebang-in-all-projects.js index 3cf10ffbe19..e3daf15bcac 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/shebang-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/shebang-in-all-projects.js @@ -1,3 +1,22 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/app --verbose +12:04:00 AM - Projects in this build: + * src/lib/tsconfig.json + * src/app/tsconfig.json + +12:04:00 AM - Project 'src/lib/tsconfig.json' is out of date because oldest output 'src/lib/module.js' is older than newest input 'src/lib/file1.ts' + +12:04:00 AM - Building project '/src/lib/tsconfig.json'... + +12:04:00 AM - Project 'src/app/tsconfig.json' is out of date because output of its dependency 'src/lib' has changed + +12:04:00 AM - Updating output of project '/src/app/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/app/tsconfig.json'... + +exitCode:: 0 + + //// [/src/app/module.js] #!someshebang lib file0 var myGlob = 20; diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/stripInternal.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/stripInternal.js index 4de45c6d0ec..6f6ca38435a 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/stripInternal.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/stripInternal.js @@ -1,3 +1,22 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/app --verbose +12:04:00 AM - Projects in this build: + * src/lib/tsconfig.json + * src/app/tsconfig.json + +12:04:00 AM - Project 'src/lib/tsconfig.json' is out of date because oldest output 'src/lib/module.js' is older than newest input 'src/lib/file1.ts' + +12:04:00 AM - Building project '/src/lib/tsconfig.json'... + +12:04:00 AM - Project 'src/app/tsconfig.json' is out of date because output of its dependency 'src/lib' has changed + +12:04:00 AM - Updating output of project '/src/app/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/app/tsconfig.json'... + +exitCode:: 0 + + //// [/src/app/module.js] /*@internal*/ var myGlob = 20; define("file1", ["require", "exports"], function (require, exports) { diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/triple-slash-refs-in-all-projects.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/triple-slash-refs-in-all-projects.js index 479ea723921..b07879caae0 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/triple-slash-refs-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-declaration-doesnt-change/triple-slash-refs-in-all-projects.js @@ -1,3 +1,22 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/app --verbose +12:04:00 AM - Projects in this build: + * src/lib/tsconfig.json + * src/app/tsconfig.json + +12:04:00 AM - Project 'src/lib/tsconfig.json' is out of date because oldest output 'src/lib/module.js' is older than newest input 'src/lib/file1.ts' + +12:04:00 AM - Building project '/src/lib/tsconfig.json'... + +12:04:00 AM - Project 'src/app/tsconfig.json' is out of date because output of its dependency 'src/lib' has changed + +12:04:00 AM - Updating output of project '/src/app/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/app/tsconfig.json'... + +exitCode:: 0 + + //// [/src/app/module.js] /// var file0Const = new libfile0(); diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-headers-change-without-dts-changes/multiple-emitHelpers-in-all-projects.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-headers-change-without-dts-changes/multiple-emitHelpers-in-all-projects.js index 54c0b8fe21e..27bdfed7421 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-headers-change-without-dts-changes/multiple-emitHelpers-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-headers-change-without-dts-changes/multiple-emitHelpers-in-all-projects.js @@ -1,3 +1,22 @@ +//// [/lib/incremental-headers-change-without-dts-changesOutput.txt] +/lib/tsc --b /src/app --verbose +12:08:00 AM - Projects in this build: + * src/lib/tsconfig.json + * src/app/tsconfig.json + +12:08:00 AM - Project 'src/lib/tsconfig.json' is out of date because oldest output 'src/lib/module.js' is older than newest input 'src/lib/file1.ts' + +12:08:00 AM - Building project '/src/lib/tsconfig.json'... + +12:08:00 AM - Project 'src/app/tsconfig.json' is out of date because output of its dependency 'src/lib' has changed + +12:08:00 AM - Updating output of project '/src/app/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/app/tsconfig.json'... + +exitCode:: 0 + + //// [/src/app/module.js] var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-headers-change-without-dts-changes/multiple-prologues-in-all-projects.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-headers-change-without-dts-changes/multiple-prologues-in-all-projects.js index ad401641be8..ae8b69e86b9 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-headers-change-without-dts-changes/multiple-prologues-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-headers-change-without-dts-changes/multiple-prologues-in-all-projects.js @@ -1,3 +1,22 @@ +//// [/lib/incremental-headers-change-without-dts-changesOutput.txt] +/lib/tsc --b /src/app --verbose +12:08:00 AM - Projects in this build: + * src/lib/tsconfig.json + * src/app/tsconfig.json + +12:08:00 AM - Project 'src/lib/tsconfig.json' is out of date because oldest output 'src/lib/module.js' is older than newest input 'src/lib/file1.ts' + +12:08:00 AM - Building project '/src/lib/tsconfig.json'... + +12:08:00 AM - Project 'src/app/tsconfig.json' is out of date because output of its dependency 'src/lib' has changed + +12:08:00 AM - Updating output of project '/src/app/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/app/tsconfig.json'... + +exitCode:: 0 + + //// [/src/app/module.d.ts.map] {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../lib/file0.ts","../lib/file1.ts","../lib/file2.ts","../lib/global.ts","file3.ts","file4.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,MAAM,KAAK,CAAC;;ICAlB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;;;ICApB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;;ACApB,QAAA,MAAM,WAAW,KAAK,CAAC;;ICAvB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;;ACApB,QAAA,MAAM,KAAK,KAAK,CAAC"} diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-headers-change-without-dts-changes/stripInternal.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-headers-change-without-dts-changes/stripInternal.js index 218681bea8f..544b25a544d 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-headers-change-without-dts-changes/stripInternal.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/incremental-headers-change-without-dts-changes/stripInternal.js @@ -1,3 +1,20 @@ +//// [/lib/incremental-headers-change-without-dts-changesOutput.txt] +/lib/tsc --b /src/app --verbose +12:08:00 AM - Projects in this build: + * src/lib/tsconfig.json + * src/app/tsconfig.json + +12:08:00 AM - Project 'src/lib/tsconfig.json' is out of date because oldest output 'src/lib/module.js' is older than newest input 'src/lib/file1.ts' + +12:08:00 AM - Building project '/src/lib/tsconfig.json'... + +12:08:00 AM - Project 'src/app/tsconfig.json' is out of date because output of its dependency 'src/lib' has changed + +12:08:00 AM - Updating output of project '/src/app/tsconfig.json'... + +exitCode:: 0 + + //// [/src/app/module.d.ts] declare module "file1" { export class normalC { diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-Build/modules-and-globals-mixed-in-amd.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/modules-and-globals-mixed-in-amd.js similarity index 95% rename from tests/baselines/reference/tsbuild/amdModulesWithOut/initial-Build/modules-and-globals-mixed-in-amd.js rename to tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/modules-and-globals-mixed-in-amd.js index 4106601d1e3..1e6b3c5f9d3 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-Build/modules-and-globals-mixed-in-amd.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/modules-and-globals-mixed-in-amd.js @@ -1,3 +1,20 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/app --verbose +12:01:00 AM - Projects in this build: + * src/lib/tsconfig.json + * src/app/tsconfig.json + +12:01:00 AM - Project 'src/lib/tsconfig.json' is out of date because output file 'src/lib/module.js' does not exist + +12:01:00 AM - Building project '/src/lib/tsconfig.json'... + +12:01:00 AM - Project 'src/app/tsconfig.json' is out of date because output file 'src/app/module.js' does not exist + +12:01:00 AM - Building project '/src/app/tsconfig.json'... + +exitCode:: 0 + + //// [/src/app/module.d.ts] declare const myGlob = 20; declare module "file1" { diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-Build/multiple-emitHelpers-in-all-projects.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/multiple-emitHelpers-in-all-projects.js similarity index 96% rename from tests/baselines/reference/tsbuild/amdModulesWithOut/initial-Build/multiple-emitHelpers-in-all-projects.js rename to tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/multiple-emitHelpers-in-all-projects.js index eeb57b9cf9e..4bef255a862 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-Build/multiple-emitHelpers-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/multiple-emitHelpers-in-all-projects.js @@ -1,3 +1,20 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/app --verbose +12:01:00 AM - Projects in this build: + * src/lib/tsconfig.json + * src/app/tsconfig.json + +12:01:00 AM - Project 'src/lib/tsconfig.json' is out of date because output file 'src/lib/module.js' does not exist + +12:01:00 AM - Building project '/src/lib/tsconfig.json'... + +12:01:00 AM - Project 'src/app/tsconfig.json' is out of date because output file 'src/app/module.js' does not exist + +12:01:00 AM - Building project '/src/app/tsconfig.json'... + +exitCode:: 0 + + //// [/src/app/file3.ts] export const z = 30; import { x } from "file1";function forappfile3Rest() { diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-Build/multiple-prologues-in-all-projects.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/multiple-prologues-in-all-projects.js similarity index 95% rename from tests/baselines/reference/tsbuild/amdModulesWithOut/initial-Build/multiple-prologues-in-all-projects.js rename to tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/multiple-prologues-in-all-projects.js index 4835019b1f9..0a28b0c5003 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-Build/multiple-prologues-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/multiple-prologues-in-all-projects.js @@ -1,3 +1,20 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/app --verbose +12:01:00 AM - Projects in this build: + * src/lib/tsconfig.json + * src/app/tsconfig.json + +12:01:00 AM - Project 'src/lib/tsconfig.json' is out of date because output file 'src/lib/module.js' does not exist + +12:01:00 AM - Building project '/src/lib/tsconfig.json'... + +12:01:00 AM - Project 'src/app/tsconfig.json' is out of date because output file 'src/app/module.js' does not exist + +12:01:00 AM - Building project '/src/app/tsconfig.json'... + +exitCode:: 0 + + //// [/src/app/file3.ts] "myPrologue" export const z = 30; diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-Build/shebang-in-all-projects.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/shebang-in-all-projects.js similarity index 95% rename from tests/baselines/reference/tsbuild/amdModulesWithOut/initial-Build/shebang-in-all-projects.js rename to tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/shebang-in-all-projects.js index eb0407a5b17..16c2c89eab9 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-Build/shebang-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/shebang-in-all-projects.js @@ -1,3 +1,20 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/app --verbose +12:01:00 AM - Projects in this build: + * src/lib/tsconfig.json + * src/app/tsconfig.json + +12:01:00 AM - Project 'src/lib/tsconfig.json' is out of date because output file 'src/lib/module.js' does not exist + +12:01:00 AM - Building project '/src/lib/tsconfig.json'... + +12:01:00 AM - Project 'src/app/tsconfig.json' is out of date because output file 'src/app/module.js' does not exist + +12:01:00 AM - Building project '/src/app/tsconfig.json'... + +exitCode:: 0 + + //// [/src/app/file3.ts] #!someshebang app file3 export const z = 30; diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-Build/stripInternal.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/stripInternal.js similarity index 97% rename from tests/baselines/reference/tsbuild/amdModulesWithOut/initial-Build/stripInternal.js rename to tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/stripInternal.js index dcac12cae9f..2d2bd9809d6 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-Build/stripInternal.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/stripInternal.js @@ -1,3 +1,20 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/app --verbose +12:01:00 AM - Projects in this build: + * src/lib/tsconfig.json + * src/app/tsconfig.json + +12:01:00 AM - Project 'src/lib/tsconfig.json' is out of date because output file 'src/lib/module.js' does not exist + +12:01:00 AM - Building project '/src/lib/tsconfig.json'... + +12:01:00 AM - Project 'src/app/tsconfig.json' is out of date because output file 'src/app/module.js' does not exist + +12:01:00 AM - Building project '/src/app/tsconfig.json'... + +exitCode:: 0 + + //// [/src/app/module.d.ts] declare module "file1" { export const x = 10; diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-Build/triple-slash-refs-in-all-projects.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/triple-slash-refs-in-all-projects.js similarity index 95% rename from tests/baselines/reference/tsbuild/amdModulesWithOut/initial-Build/triple-slash-refs-in-all-projects.js rename to tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/triple-slash-refs-in-all-projects.js index 30f8da909cd..50259e2c93d 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-Build/triple-slash-refs-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/triple-slash-refs-in-all-projects.js @@ -1,3 +1,20 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/app --verbose +12:01:00 AM - Projects in this build: + * src/lib/tsconfig.json + * src/app/tsconfig.json + +12:01:00 AM - Project 'src/lib/tsconfig.json' is out of date because output file 'src/lib/module.js' does not exist + +12:01:00 AM - Building project '/src/lib/tsconfig.json'... + +12:01:00 AM - Project 'src/app/tsconfig.json' is out of date because output file 'src/app/module.js' does not exist + +12:01:00 AM - Building project '/src/app/tsconfig.json'... + +exitCode:: 0 + + //// [/src/app/file4.ts] /// const file4Const = new appfile4(); diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-Build/when-the-module-resolution-finds-original-source-file.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/when-the-module-resolution-finds-original-source-file.js similarity index 95% rename from tests/baselines/reference/tsbuild/amdModulesWithOut/initial-Build/when-the-module-resolution-finds-original-source-file.js rename to tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/when-the-module-resolution-finds-original-source-file.js index 3611d355563..9bc7340630f 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-Build/when-the-module-resolution-finds-original-source-file.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/when-the-module-resolution-finds-original-source-file.js @@ -1,3 +1,20 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc -b /src/app --verbose +12:00:00 AM - Projects in this build: + * src/lib/tsconfig.json + * src/app/tsconfig.json + +12:00:00 AM - Project 'src/lib/tsconfig.json' is out of date because output file 'src/module.js' does not exist + +12:00:00 AM - Building project '/src/lib/tsconfig.json'... + +12:00:00 AM - Project 'src/app/tsconfig.json' is out of date because output file 'src/app/module.js' does not exist + +12:00:00 AM - Building project '/src/app/tsconfig.json'... + +exitCode:: 0 + + //// [/src/app/file3.ts] export const z = 30; import { x } from "lib/file1"; diff --git a/tests/baselines/reference/tsbuild/emitDeclarationOnly/incremental-declaration-changes/only-dts-output-in-circular-import-project-with-emitDeclarationOnly-and-declarationMap.js b/tests/baselines/reference/tsbuild/emitDeclarationOnly/incremental-declaration-changes/only-dts-output-in-circular-import-project-with-emitDeclarationOnly-and-declarationMap.js index f4675cfcd15..d2d70c1b8be 100644 --- a/tests/baselines/reference/tsbuild/emitDeclarationOnly/incremental-declaration-changes/only-dts-output-in-circular-import-project-with-emitDeclarationOnly-and-declarationMap.js +++ b/tests/baselines/reference/tsbuild/emitDeclarationOnly/incremental-declaration-changes/only-dts-output-in-circular-import-project-with-emitDeclarationOnly-and-declarationMap.js @@ -1,3 +1,15 @@ +//// [/lib/incremental-declaration-changesOutput.txt] +/lib/tsc --b /src --verbose +12:04:00 AM - Projects in this build: + * src/tsconfig.json + +12:04:00 AM - Project 'src/tsconfig.json' is out of date because oldest output 'src/lib/a.d.ts' is older than newest input 'src/src/a.ts' + +12:04:00 AM - Building project '/src/tsconfig.json'... + +exitCode:: 0 + + //// [/src/lib/a.d.ts] import { B } from "./b"; export interface A { diff --git a/tests/baselines/reference/tsbuild/emitDeclarationOnly/incremental-declaration-changes/only-dts-output-in-circular-import-project-with-emitDeclarationOnly.js b/tests/baselines/reference/tsbuild/emitDeclarationOnly/incremental-declaration-changes/only-dts-output-in-circular-import-project-with-emitDeclarationOnly.js index a1297732a88..6e6f2bb1805 100644 --- a/tests/baselines/reference/tsbuild/emitDeclarationOnly/incremental-declaration-changes/only-dts-output-in-circular-import-project-with-emitDeclarationOnly.js +++ b/tests/baselines/reference/tsbuild/emitDeclarationOnly/incremental-declaration-changes/only-dts-output-in-circular-import-project-with-emitDeclarationOnly.js @@ -1,3 +1,15 @@ +//// [/lib/incremental-declaration-changesOutput.txt] +/lib/tsc --b /src --verbose +12:04:00 AM - Projects in this build: + * src/tsconfig.json + +12:04:00 AM - Project 'src/tsconfig.json' is out of date because oldest output 'src/lib/a.d.ts' is older than newest input 'src/src/a.ts' + +12:04:00 AM - Building project '/src/tsconfig.json'... + +exitCode:: 0 + + //// [/src/lib/a.d.ts] import { B } from "./b"; export interface A { diff --git a/tests/baselines/reference/tsbuild/emitDeclarationOnly/incremental-declaration-changes/only-dts-output-in-non-circular-imports-project-with-emitDeclarationOnly.js b/tests/baselines/reference/tsbuild/emitDeclarationOnly/incremental-declaration-changes/only-dts-output-in-non-circular-imports-project-with-emitDeclarationOnly.js index c5eb746e843..8bcb33bced7 100644 --- a/tests/baselines/reference/tsbuild/emitDeclarationOnly/incremental-declaration-changes/only-dts-output-in-non-circular-imports-project-with-emitDeclarationOnly.js +++ b/tests/baselines/reference/tsbuild/emitDeclarationOnly/incremental-declaration-changes/only-dts-output-in-non-circular-imports-project-with-emitDeclarationOnly.js @@ -1,3 +1,15 @@ +//// [/lib/incremental-declaration-changesOutput.txt] +/lib/tsc --b /src --verbose +12:04:00 AM - Projects in this build: + * src/tsconfig.json + +12:04:00 AM - Project 'src/tsconfig.json' is out of date because oldest output 'src/lib/a.d.ts' is older than newest input 'src/src/a.ts' + +12:04:00 AM - Building project '/src/tsconfig.json'... + +exitCode:: 0 + + //// [/src/lib/a.d.ts] export declare class B { prop: string; diff --git a/tests/baselines/reference/tsbuild/emitDeclarationOnly/incremental-declaration-doesnt-change/only-dts-output-in-non-circular-imports-project-with-emitDeclarationOnly.js b/tests/baselines/reference/tsbuild/emitDeclarationOnly/incremental-declaration-doesnt-change/only-dts-output-in-non-circular-imports-project-with-emitDeclarationOnly.js index 0eb46f39556..bdfcb1e826f 100644 --- a/tests/baselines/reference/tsbuild/emitDeclarationOnly/incremental-declaration-doesnt-change/only-dts-output-in-non-circular-imports-project-with-emitDeclarationOnly.js +++ b/tests/baselines/reference/tsbuild/emitDeclarationOnly/incremental-declaration-doesnt-change/only-dts-output-in-non-circular-imports-project-with-emitDeclarationOnly.js @@ -1,3 +1,17 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src --verbose +12:08:00 AM - Projects in this build: + * src/tsconfig.json + +12:08:00 AM - Project 'src/tsconfig.json' is out of date because oldest output 'src/lib/a.d.ts' is older than newest input 'src/src/a.ts' + +12:08:00 AM - Building project '/src/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/tsconfig.json'... + +exitCode:: 0 + + //// [/src/lib/a.d.ts] file written with same contents //// [/src/lib/a.d.ts.map] {"version":3,"file":"a.d.ts","sourceRoot":"","sources":["../src/a.ts"],"names":[],"mappings":"AAAA,qBAAa,CAAC;IAAG,IAAI,SAAW;CAAE;AAGlC,MAAM,WAAW,CAAC;IAChB,CAAC,EAAE,CAAC,CAAC;CACN"} diff --git a/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-Build/only-dts-output-in-circular-import-project-with-emitDeclarationOnly-and-declarationMap.js b/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-build/only-dts-output-in-circular-import-project-with-emitDeclarationOnly-and-declarationMap.js similarity index 92% rename from tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-Build/only-dts-output-in-circular-import-project-with-emitDeclarationOnly-and-declarationMap.js rename to tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-build/only-dts-output-in-circular-import-project-with-emitDeclarationOnly-and-declarationMap.js index 838bf28950f..38d8974e900 100644 --- a/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-Build/only-dts-output-in-circular-import-project-with-emitDeclarationOnly-and-declarationMap.js +++ b/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-build/only-dts-output-in-circular-import-project-with-emitDeclarationOnly-and-declarationMap.js @@ -1,3 +1,15 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src --verbose +12:01:00 AM - Projects in this build: + * src/tsconfig.json + +12:01:00 AM - Project 'src/tsconfig.json' is out of date because output file 'src/lib/a.d.ts' does not exist + +12:01:00 AM - Building project '/src/tsconfig.json'... + +exitCode:: 0 + + //// [/src/lib/a.d.ts] import { B } from "./b"; export interface A { diff --git a/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-Build/only-dts-output-in-circular-import-project-with-emitDeclarationOnly.js b/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-build/only-dts-output-in-circular-import-project-with-emitDeclarationOnly.js similarity index 93% rename from tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-Build/only-dts-output-in-circular-import-project-with-emitDeclarationOnly.js rename to tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-build/only-dts-output-in-circular-import-project-with-emitDeclarationOnly.js index d07b0914c32..6f2bc263212 100644 --- a/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-Build/only-dts-output-in-circular-import-project-with-emitDeclarationOnly.js +++ b/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-build/only-dts-output-in-circular-import-project-with-emitDeclarationOnly.js @@ -1,3 +1,15 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src --verbose +12:01:00 AM - Projects in this build: + * src/tsconfig.json + +12:01:00 AM - Project 'src/tsconfig.json' is out of date because output file 'src/lib/a.d.ts' does not exist + +12:01:00 AM - Building project '/src/tsconfig.json'... + +exitCode:: 0 + + //// [/src/lib/a.d.ts] import { B } from "./b"; export interface A { diff --git a/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-Build/only-dts-output-in-non-circular-imports-project-with-emitDeclarationOnly.js b/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-build/only-dts-output-in-non-circular-imports-project-with-emitDeclarationOnly.js similarity index 91% rename from tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-Build/only-dts-output-in-non-circular-imports-project-with-emitDeclarationOnly.js rename to tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-build/only-dts-output-in-non-circular-imports-project-with-emitDeclarationOnly.js index 86f7dc6e8bc..aabaf41d53b 100644 --- a/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-Build/only-dts-output-in-non-circular-imports-project-with-emitDeclarationOnly.js +++ b/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-build/only-dts-output-in-non-circular-imports-project-with-emitDeclarationOnly.js @@ -1,3 +1,15 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src --verbose +12:01:00 AM - Projects in this build: + * src/tsconfig.json + +12:01:00 AM - Project 'src/tsconfig.json' is out of date because output file 'src/lib/a.d.ts' does not exist + +12:01:00 AM - Building project '/src/tsconfig.json'... + +exitCode:: 0 + + //// [/src/lib/a.d.ts] export declare class B { prop: string; diff --git a/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/incremental-declaration-changes/inferred-type-from-transitive-module-with-isolatedModules.js b/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/incremental-declaration-changes/inferred-type-from-transitive-module-with-isolatedModules.js index f8dfdc7e146..a95215cf77f 100644 --- a/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/incremental-declaration-changes/inferred-type-from-transitive-module-with-isolatedModules.js +++ b/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/incremental-declaration-changes/inferred-type-from-transitive-module-with-isolatedModules.js @@ -1,3 +1,17 @@ +//// [/lib/incremental-declaration-changesOutput.txt] +/lib/tsc --b /src --verbose +12:04:00 AM - Projects in this build: + * src/tsconfig.json + +12:04:00 AM - Project 'src/tsconfig.json' is out of date because oldest output 'src/obj/bar.js' is older than newest input 'src/bar.ts' + +12:04:00 AM - Building project '/src/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/tsconfig.json'... + +exitCode:: 0 + + //// [/src/bar.ts] interface RawAction { (...args: any[]): Promise | void; diff --git a/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/incremental-declaration-changes/inferred-type-from-transitive-module.js b/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/incremental-declaration-changes/inferred-type-from-transitive-module.js index 556f32082f5..5cd9097a200 100644 --- a/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/incremental-declaration-changes/inferred-type-from-transitive-module.js +++ b/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/incremental-declaration-changes/inferred-type-from-transitive-module.js @@ -1,3 +1,17 @@ +//// [/lib/incremental-declaration-changesOutput.txt] +/lib/tsc --b /src --verbose +12:04:00 AM - Projects in this build: + * src/tsconfig.json + +12:04:00 AM - Project 'src/tsconfig.json' is out of date because oldest output 'src/obj/bar.js' is older than newest input 'src/bar.ts' + +12:04:00 AM - Building project '/src/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/tsconfig.json'... + +exitCode:: 0 + + //// [/src/bar.ts] interface RawAction { (...args: any[]): Promise | void; diff --git a/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/incremental-declaration-changes/reports-errors-in-files-affected-by-change-in-signature-with-isolatedModules.js b/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/incremental-declaration-changes/reports-errors-in-files-affected-by-change-in-signature-with-isolatedModules.js new file mode 100644 index 00000000000..a00425b57a8 --- /dev/null +++ b/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/incremental-declaration-changes/reports-errors-in-files-affected-by-change-in-signature-with-isolatedModules.js @@ -0,0 +1,24 @@ +//// [/lib/incremental-declaration-changesOutput.txt] +/lib/tsc --b /src --verbose +12:04:00 AM - Projects in this build: + * src/tsconfig.json + +12:04:00 AM - Project 'src/tsconfig.json' is out of date because oldest output 'src/obj/bar.js' is older than newest input 'src/bar.ts' + +12:04:00 AM - Building project '/src/tsconfig.json'... + +src/lazyIndex.ts(4,5): error TS2554: Expected 0 arguments, but got 1. +exitCode:: 1 + + +//// [/src/bar.ts] +interface RawAction { + (...args: any[]): Promise | void; +} +interface ActionFactory { + (target: T): T; +} +declare function foo(): ActionFactory; +export default foo()(function foobar(): void { +}); + diff --git a/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-Build/inferred-type-from-transitive-module-with-isolatedModules.js b/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-build/inferred-type-from-transitive-module-with-isolatedModules.js similarity index 93% rename from tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-Build/inferred-type-from-transitive-module-with-isolatedModules.js rename to tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-build/inferred-type-from-transitive-module-with-isolatedModules.js index 568116485a4..93a7e296495 100644 --- a/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-Build/inferred-type-from-transitive-module-with-isolatedModules.js +++ b/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-build/inferred-type-from-transitive-module-with-isolatedModules.js @@ -1,3 +1,15 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src --verbose +12:01:00 AM - Projects in this build: + * src/tsconfig.json + +12:01:00 AM - Project 'src/tsconfig.json' is out of date because output file 'src/obj/bar.js' does not exist + +12:01:00 AM - Building project '/src/tsconfig.json'... + +exitCode:: 0 + + //// [/src/obj/bar.d.ts] declare const _default: (param: string) => void; export default _default; diff --git a/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-Build/inferred-type-from-transitive-module.js b/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-build/inferred-type-from-transitive-module.js similarity index 93% rename from tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-Build/inferred-type-from-transitive-module.js rename to tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-build/inferred-type-from-transitive-module.js index a04669bd971..45a284dc09c 100644 --- a/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-Build/inferred-type-from-transitive-module.js +++ b/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-build/inferred-type-from-transitive-module.js @@ -1,3 +1,15 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src --verbose +12:01:00 AM - Projects in this build: + * src/tsconfig.json + +12:01:00 AM - Project 'src/tsconfig.json' is out of date because output file 'src/obj/bar.js' does not exist + +12:01:00 AM - Building project '/src/tsconfig.json'... + +exitCode:: 0 + + //// [/src/obj/bar.d.ts] declare const _default: (param: string) => void; export default _default; diff --git a/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-build/reports-errors-in-files-affected-by-change-in-signature-with-isolatedModules.js b/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-build/reports-errors-in-files-affected-by-change-in-signature-with-isolatedModules.js new file mode 100644 index 00000000000..39ad2d40a31 --- /dev/null +++ b/tests/baselines/reference/tsbuild/inferredTypeFromTransitiveModule/initial-build/reports-errors-in-files-affected-by-change-in-signature-with-isolatedModules.js @@ -0,0 +1,163 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src --verbose +12:01:00 AM - Projects in this build: + * src/tsconfig.json + +12:01:00 AM - Project 'src/tsconfig.json' is out of date because output file 'src/obj/bar.js' does not exist + +12:01:00 AM - Building project '/src/tsconfig.json'... + +exitCode:: 0 + + +//// [/src/lazyIndex.ts] +export { default as bar } from './bar'; + +import { default as bar } from './bar'; +bar("hello"); + +//// [/src/obj/bar.d.ts] +declare const _default: (param: string) => void; +export default _default; + + +//// [/src/obj/bar.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = foo()(function foobar(param) { +}); + + +//// [/src/obj/bundling.d.ts] +export declare class LazyModule { + private importCallback; + constructor(importCallback: () => Promise); +} +export declare class LazyAction any, TModule> { + constructor(_lazyModule: LazyModule, _getter: (module: TModule) => TAction); +} + + +//// [/src/obj/bundling.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var LazyModule = /** @class */ (function () { + function LazyModule(importCallback) { + this.importCallback = importCallback; + } + return LazyModule; +}()); +exports.LazyModule = LazyModule; +var LazyAction = /** @class */ (function () { + function LazyAction(_lazyModule, _getter) { + } + return LazyAction; +}()); +exports.LazyAction = LazyAction; + + +//// [/src/obj/index.d.ts] +import { LazyAction } from './bundling'; +export declare const lazyBar: LazyAction<(param: string) => void, typeof import("./lazyIndex")>; + + +//// [/src/obj/index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var bundling_1 = require("./bundling"); +var lazyModule = new bundling_1.LazyModule(function () { + return Promise.resolve().then(function () { return require('./lazyIndex'); }); +}); +exports.lazyBar = new bundling_1.LazyAction(lazyModule, function (m) { return m.bar; }); + + +//// [/src/obj/lazyIndex.d.ts] +export { default as bar } from './bar'; + + +//// [/src/obj/lazyIndex.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var bar_1 = require("./bar"); +exports.bar = bar_1.default; +var bar_2 = require("./bar"); +bar_2.default("hello"); + + +//// [/src/obj/tsconfig.tsbuildinfo] +{ + "program": { + "fileInfos": { + "../../lib/lib.d.ts": { + "version": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "signature": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };" + }, + "../bar.ts": { + "version": "5936740878-interface RawAction {\r\n (...args: any[]): Promise | void;\r\n}\r\ninterface ActionFactory {\r\n (target: T): T;\r\n}\r\ndeclare function foo(): ActionFactory;\r\nexport default foo()(function foobar(param: string): void {\r\n});", + "signature": "11191036521-declare const _default: (param: string) => void;\r\nexport default _default;\r\n" + }, + "../bundling.ts": { + "version": "-21659820217-export class LazyModule {\r\n constructor(private importCallback: () => Promise) {}\r\n}\r\n\r\nexport class LazyAction<\r\n TAction extends (...args: any[]) => any,\r\n TModule\r\n> {\r\n constructor(_lazyModule: LazyModule, _getter: (module: TModule) => TAction) {\r\n }\r\n}\r\n", + "signature": "-40032907372-export declare class LazyModule {\r\n private importCallback;\r\n constructor(importCallback: () => Promise);\r\n}\r\nexport declare class LazyAction any, TModule> {\r\n constructor(_lazyModule: LazyModule, _getter: (module: TModule) => TAction);\r\n}\r\n" + }, + "../global.d.ts": { + "version": "-9780226215-interface PromiseConstructor {\r\n new (): Promise;\r\n}\r\ndeclare var Promise: PromiseConstructor;\r\ninterface Promise {\r\n}", + "signature": "-9780226215-interface PromiseConstructor {\r\n new (): Promise;\r\n}\r\ndeclare var Promise: PromiseConstructor;\r\ninterface Promise {\r\n}" + }, + "../lazyindex.ts": { + "version": "3017320451-export { default as bar } from './bar';\n\nimport { default as bar } from './bar';\nbar(\"hello\");", + "signature": "-6224542381-export { default as bar } from './bar';\r\n" + }, + "../index.ts": { + "version": "-11602502901-import { LazyAction, LazyModule } from './bundling';\r\nconst lazyModule = new LazyModule(() =>\r\n import('./lazyIndex')\r\n);\r\nexport const lazyBar = new LazyAction(lazyModule, m => m.bar);", + "signature": "18468008756-import { LazyAction } from './bundling';\r\nexport declare const lazyBar: LazyAction<(param: string) => void, typeof import(\"./lazyIndex\")>;\r\n" + } + }, + "options": { + "target": 1, + "declaration": true, + "outDir": "./", + "incremental": true, + "isolatedModules": true, + "configFilePath": "../tsconfig.json" + }, + "referencedMap": { + "../index.ts": [ + "../bundling.ts", + "../lazyindex.ts" + ], + "../lazyindex.ts": [ + "../bar.ts" + ] + }, + "exportedModulesMap": { + "../index.ts": [ + "../bundling.ts", + "../lazyindex.ts" + ], + "../lazyindex.ts": [ + "../bar.ts" + ] + }, + "semanticDiagnosticsPerFile": [ + "../../lib/lib.d.ts", + "../bar.ts", + "../bundling.ts", + "../global.d.ts", + "../index.ts", + "../lazyindex.ts" + ] + }, + "version": "FakeTSVersion" +} + +//// [/src/tsconfig.json] +{ + "compilerOptions": { + "target": "es5", + "declaration": true, + "outDir": "obj", + "incremental": true, "isolatedModules": true + } +} + diff --git a/tests/baselines/reference/tsbuild/lateBoundSymbol/incremental-declaration-doesnt-change/interface-is-merged-and-contains-late-bound-member.js b/tests/baselines/reference/tsbuild/lateBoundSymbol/incremental-declaration-doesnt-change/interface-is-merged-and-contains-late-bound-member.js index bdd69739968..ffa834ba467 100644 --- a/tests/baselines/reference/tsbuild/lateBoundSymbol/incremental-declaration-doesnt-change/interface-is-merged-and-contains-late-bound-member.js +++ b/tests/baselines/reference/tsbuild/lateBoundSymbol/incremental-declaration-doesnt-change/interface-is-merged-and-contains-late-bound-member.js @@ -1,3 +1,17 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/tsconfig.json --verbose +12:04:00 AM - Projects in this build: + * src/tsconfig.json + +12:04:00 AM - Project 'src/tsconfig.json' is out of date because oldest output 'src/src/hkt.js' is older than newest input 'src/src/main.ts' + +12:04:00 AM - Building project '/src/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/tsconfig.json'... + +exitCode:: 0 + + //// [/src/src/main.js] "use strict"; exports.__esModule = true; diff --git a/tests/baselines/reference/tsbuild/lateBoundSymbol/initial-Build/interface-is-merged-and-contains-late-bound-member.js b/tests/baselines/reference/tsbuild/lateBoundSymbol/initial-build/interface-is-merged-and-contains-late-bound-member.js similarity index 88% rename from tests/baselines/reference/tsbuild/lateBoundSymbol/initial-Build/interface-is-merged-and-contains-late-bound-member.js rename to tests/baselines/reference/tsbuild/lateBoundSymbol/initial-build/interface-is-merged-and-contains-late-bound-member.js index 949eb773431..86d36097454 100644 --- a/tests/baselines/reference/tsbuild/lateBoundSymbol/initial-Build/interface-is-merged-and-contains-late-bound-member.js +++ b/tests/baselines/reference/tsbuild/lateBoundSymbol/initial-build/interface-is-merged-and-contains-late-bound-member.js @@ -1,3 +1,15 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/tsconfig.json --verbose +12:01:00 AM - Projects in this build: + * src/tsconfig.json + +12:01:00 AM - Project 'src/tsconfig.json' is out of date because output file 'src/src/hkt.js' does not exist + +12:01:00 AM - Building project '/src/tsconfig.json'... + +exitCode:: 0 + + //// [/src/src/hkt.js] "use strict"; exports.__esModule = true; diff --git a/tests/baselines/reference/tsbuild/moduleSpecifiers/initial-Build/synthesized-module-specifiers-resolve-correctly.js b/tests/baselines/reference/tsbuild/moduleSpecifiers/initial-build/synthesized-module-specifiers-resolve-correctly.js similarity index 73% rename from tests/baselines/reference/tsbuild/moduleSpecifiers/initial-Build/synthesized-module-specifiers-resolve-correctly.js rename to tests/baselines/reference/tsbuild/moduleSpecifiers/initial-build/synthesized-module-specifiers-resolve-correctly.js index cd12638d637..fb5eae55d7c 100644 --- a/tests/baselines/reference/tsbuild/moduleSpecifiers/initial-Build/synthesized-module-specifiers-resolve-correctly.js +++ b/tests/baselines/reference/tsbuild/moduleSpecifiers/initial-build/synthesized-module-specifiers-resolve-correctly.js @@ -1,23 +1,47 @@ -//// [/lib/src/common/nominal.d.ts] +//// [/lib/initial-buildOutput.txt] +/lib/tsc -b /src --verbose +12:00:00 AM - Projects in this build: + * src/solution/common/tsconfig.json + * src/solution/sub-project/tsconfig.json + * src/solution/sub-project-2/tsconfig.json + * src/solution/tsconfig.json + * src/tsconfig.json + +12:00:00 AM - Project 'src/solution/common/tsconfig.json' is out of date because output file 'src/lib/solution/common/nominal.js' does not exist + +12:00:00 AM - Building project '/src/solution/common/tsconfig.json'... + +12:00:00 AM - Project 'src/solution/sub-project/tsconfig.json' is out of date because output file 'src/lib/solution/sub-project/index.js' does not exist + +12:00:00 AM - Building project '/src/solution/sub-project/tsconfig.json'... + +12:00:00 AM - Project 'src/solution/sub-project-2/tsconfig.json' is out of date because output file 'src/lib/solution/sub-project-2/index.js' does not exist + +12:00:00 AM - Building project '/src/solution/sub-project-2/tsconfig.json'... + +exitCode:: 0 + + +//// [/src/lib/solution/common/nominal.d.ts] export declare type Nominal = T & { [Symbol.species]: Name; }; -//// [/lib/src/common/nominal.js] +//// [/src/lib/solution/common/nominal.js] "use strict"; exports.__esModule = true; -//// [/lib/src/common/tsconfig.tsbuildinfo] +//// [/src/lib/solution/common/tsconfig.tsbuildinfo] { "program": { "fileInfos": { - "../../lib.d.ts": { + "../../../../lib/lib.d.ts": { "version": "-32082413277-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };\ninterface SymbolConstructor {\n readonly species: symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\n", "signature": "-32082413277-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };\ninterface SymbolConstructor {\n readonly species: symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\n" }, - "../../../src/common/nominal.ts": { + "../../../solution/common/nominal.ts": { "version": "-24498031910-export declare type Nominal = T & {\n [Symbol.species]: Name;\n};\n", "signature": "-9513375615-export declare type Nominal = T & {\r\n [Symbol.species]: Name;\r\n};\r\n" } @@ -27,41 +51,41 @@ exports.__esModule = true; "rootDir": "../../..", "outDir": "../..", "composite": true, - "configFilePath": "../../../src/common/tsconfig.json" + "configFilePath": "../../../solution/common/tsconfig.json" }, "referencedMap": {}, "exportedModulesMap": {}, "semanticDiagnosticsPerFile": [ - "../../../src/common/nominal.ts", - "../../lib.d.ts" + "../../../../lib/lib.d.ts", + "../../../solution/common/nominal.ts" ] }, "version": "FakeTSVersion" } -//// [/lib/src/sub-project/index.d.ts] +//// [/src/lib/solution/sub-project/index.d.ts] import { Nominal } from '../common/nominal'; export declare type MyNominal = Nominal; -//// [/lib/src/sub-project/index.js] +//// [/src/lib/solution/sub-project/index.js] "use strict"; exports.__esModule = true; -//// [/lib/src/sub-project/tsconfig.tsbuildinfo] +//// [/src/lib/solution/sub-project/tsconfig.tsbuildinfo] { "program": { "fileInfos": { - "../../lib.d.ts": { + "../../../../lib/lib.d.ts": { "version": "-32082413277-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };\ninterface SymbolConstructor {\n readonly species: symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\n", "signature": "-32082413277-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };\ninterface SymbolConstructor {\n readonly species: symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\n" }, - "../../../src/common/nominal.ts": { + "../../../solution/common/nominal.ts": { "version": "-9513375615-export declare type Nominal = T & {\r\n [Symbol.species]: Name;\r\n};\r\n", "signature": "-9513375615-export declare type Nominal = T & {\r\n [Symbol.species]: Name;\r\n};\r\n" }, - "../../../src/sub-project/index.ts": { + "../../../solution/sub-project/index.ts": { "version": "-22894055505-import { Nominal } from '../common/nominal';\n\nexport type MyNominal = Nominal;\n", "signature": "-21416888433-import { Nominal } from '../common/nominal';\r\nexport declare type MyNominal = Nominal;\r\n" } @@ -71,28 +95,28 @@ exports.__esModule = true; "rootDir": "../../..", "outDir": "../..", "composite": true, - "configFilePath": "../../../src/sub-project/tsconfig.json" + "configFilePath": "../../../solution/sub-project/tsconfig.json" }, "referencedMap": { - "../../../src/sub-project/index.ts": [ + "../../../solution/sub-project/index.ts": [ "../common/nominal.d.ts" ] }, "exportedModulesMap": { - "../../../src/sub-project/index.ts": [ + "../../../solution/sub-project/index.ts": [ "../common/nominal.d.ts" ] }, "semanticDiagnosticsPerFile": [ - "../../../src/common/nominal.ts", - "../../../src/sub-project/index.ts", - "../../lib.d.ts" + "../../../../lib/lib.d.ts", + "../../../solution/common/nominal.ts", + "../../../solution/sub-project/index.ts" ] }, "version": "FakeTSVersion" } -//// [/lib/src/sub-project-2/index.d.ts] +//// [/src/lib/solution/sub-project-2/index.d.ts] declare const variable: { key: import("../common/nominal").Nominal; }; @@ -100,7 +124,7 @@ export declare function getVar(): keyof typeof variable; export {}; -//// [/lib/src/sub-project-2/index.js] +//// [/src/lib/solution/sub-project-2/index.js] "use strict"; exports.__esModule = true; var variable = { @@ -112,23 +136,23 @@ function getVar() { exports.getVar = getVar; -//// [/lib/src/sub-project-2/tsconfig.tsbuildinfo] +//// [/src/lib/solution/sub-project-2/tsconfig.tsbuildinfo] { "program": { "fileInfos": { - "../../lib.d.ts": { + "../../../../lib/lib.d.ts": { "version": "-32082413277-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };\ninterface SymbolConstructor {\n readonly species: symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\n", "signature": "-32082413277-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };\ninterface SymbolConstructor {\n readonly species: symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\n" }, - "../../../src/common/nominal.ts": { + "../../../solution/common/nominal.ts": { "version": "-9513375615-export declare type Nominal = T & {\r\n [Symbol.species]: Name;\r\n};\r\n", "signature": "-9513375615-export declare type Nominal = T & {\r\n [Symbol.species]: Name;\r\n};\r\n" }, - "../../../src/sub-project/index.ts": { + "../../../solution/sub-project/index.ts": { "version": "-21416888433-import { Nominal } from '../common/nominal';\r\nexport declare type MyNominal = Nominal;\r\n", "signature": "-21416888433-import { Nominal } from '../common/nominal';\r\nexport declare type MyNominal = Nominal;\r\n" }, - "../../../src/sub-project-2/index.ts": { + "../../../solution/sub-project-2/index.ts": { "version": "-13939373533-import { MyNominal } from '../sub-project/index';\n\nconst variable = {\n key: 'value' as MyNominal,\n};\n\nexport function getVar(): keyof typeof variable {\n return 'key';\n}\n", "signature": "-17233212183-declare const variable: {\r\n key: import(\"../common/nominal\").Nominal;\r\n};\r\nexport declare function getVar(): keyof typeof variable;\r\nexport {};\r\n" } @@ -138,29 +162,29 @@ exports.getVar = getVar; "rootDir": "../../..", "outDir": "../..", "composite": true, - "configFilePath": "../../../src/sub-project-2/tsconfig.json" + "configFilePath": "../../../solution/sub-project-2/tsconfig.json" }, "referencedMap": { - "../../../src/sub-project-2/index.ts": [ + "../../../solution/sub-project-2/index.ts": [ "../sub-project/index.d.ts" ], - "../../../src/sub-project/index.ts": [ + "../../../solution/sub-project/index.ts": [ "../common/nominal.d.ts" ] }, "exportedModulesMap": { - "../../../src/sub-project-2/index.ts": [ + "../../../solution/sub-project-2/index.ts": [ "../common/nominal.d.ts" ], - "../../../src/sub-project/index.ts": [ + "../../../solution/sub-project/index.ts": [ "../common/nominal.d.ts" ] }, "semanticDiagnosticsPerFile": [ - "../../../src/common/nominal.ts", - "../../../src/sub-project-2/index.ts", - "../../../src/sub-project/index.ts", - "../../lib.d.ts" + "../../../../lib/lib.d.ts", + "../../../solution/common/nominal.ts", + "../../../solution/sub-project-2/index.ts", + "../../../solution/sub-project/index.ts" ] }, "version": "FakeTSVersion" diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/baseline-sectioned-sourcemaps.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/baseline-sectioned-sourcemaps.js index b8705b1b03d..136509b59b8 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/baseline-sectioned-sourcemaps.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/baseline-sectioned-sourcemaps.js @@ -1,3 +1,42 @@ +//// [/lib/incremental-declaration-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because oldest output 'src/third/thirdjs/output/third-output.js' is older than newest input 'src/first' + +12:04:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 2, + "/src/2/second-output.tsbuildinfo": 1, + "/src/2/second-output.d.ts": 1, + "/src/third/third_part1.ts": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1, + "/src/third/thirdjs/output/third-output.d.ts": 1 +} + //// [/src/first/bin/first-output.d.ts] interface TheFirst { none: any; diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/emitHelpers-in-all-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/emitHelpers-in-all-projects.js index f3a11792c1f..605e02ffcc8 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/emitHelpers-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/emitHelpers-in-all-projects.js @@ -1,3 +1,42 @@ +//// [/lib/incremental-declaration-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because oldest output 'src/third/thirdjs/output/third-output.js' is older than newest input 'src/first' + +12:04:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 2, + "/src/2/second-output.tsbuildinfo": 1, + "/src/2/second-output.d.ts": 1, + "/src/third/third_part1.ts": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1, + "/src/third/thirdjs/output/third-output.d.ts": 1 +} + //// [/src/first/bin/first-output.d.ts] interface TheFirst { none: any; diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/multiple-prologues-in-all-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/multiple-prologues-in-all-projects.js index 3b3e6b136dc..a10f26edcc3 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/multiple-prologues-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/multiple-prologues-in-all-projects.js @@ -1,3 +1,42 @@ +//// [/lib/incremental-declaration-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because oldest output 'src/third/thirdjs/output/third-output.js' is older than newest input 'src/first' + +12:04:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 2, + "/src/2/second-output.tsbuildinfo": 1, + "/src/2/second-output.d.ts": 1, + "/src/third/third_part1.ts": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1, + "/src/third/thirdjs/output/third-output.d.ts": 1 +} + //// [/src/first/bin/first-output.d.ts] interface TheFirst { none: any; diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/shebang-in-all-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/shebang-in-all-projects.js index 5dc312d58ce..874c818de64 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/shebang-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/shebang-in-all-projects.js @@ -1,3 +1,42 @@ +//// [/lib/incremental-declaration-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because oldest output 'src/third/thirdjs/output/third-output.js' is older than newest input 'src/first' + +12:04:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 2, + "/src/2/second-output.tsbuildinfo": 1, + "/src/2/second-output.d.ts": 1, + "/src/third/third_part1.ts": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1, + "/src/third/thirdjs/output/third-output.d.ts": 1 +} + //// [/src/first/bin/first-output.d.ts] #!someshebang first first_PART1 interface TheFirst { diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/strict-in-all-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/strict-in-all-projects.js index 84d8de40064..9d7471bf95c 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/strict-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/strict-in-all-projects.js @@ -1,3 +1,42 @@ +//// [/lib/incremental-declaration-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because oldest output 'src/third/thirdjs/output/third-output.js' is older than newest input 'src/first' + +12:04:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 2, + "/src/2/second-output.tsbuildinfo": 1, + "/src/2/second-output.d.ts": 1, + "/src/third/third_part1.ts": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1, + "/src/third/thirdjs/output/third-output.d.ts": 1 +} + //// [/src/first/bin/first-output.d.ts] interface TheFirst { none: any; diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/stripInternal-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/stripInternal-when-one-two-three-are-prepended-in-order.js index 0b7ac11a100..c218edfa8a9 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/stripInternal-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/stripInternal-when-one-two-three-are-prepended-in-order.js @@ -1,3 +1,46 @@ +//// [/lib/incremental-declaration-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is out of date because oldest output 'src/2/second-output.js' is older than newest input 'src/first' + +12:04:00 AM - Building project '/src/second/tsconfig.json'... + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because oldest output 'src/third/thirdjs/output/third-output.js' is older than newest input 'src/second' + +12:04:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 2, + "/src/second/second_part1.ts": 1, + "/src/second/second_part2.ts": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts": 2, + "/src/third/third_part1.ts": 1, + "/src/2/second-output.tsbuildinfo": 1, + "/src/2/second-output.js": 1, + "/src/2/second-output.js.map": 1, + "/src/2/second-output.d.ts.map": 1, + "/src/third/thirdjs/output/third-output.d.ts": 1 +} + //// [/src/2/second-output.d.ts] interface TheFirst { none: any; diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/stripInternal.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/stripInternal.js index 031180b66ce..397f586217e 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/stripInternal.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/stripInternal.js @@ -1,3 +1,42 @@ +//// [/lib/incremental-declaration-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because oldest output 'src/third/thirdjs/output/third-output.js' is older than newest input 'src/first' + +12:04:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 2, + "/src/2/second-output.tsbuildinfo": 1, + "/src/2/second-output.d.ts": 1, + "/src/third/third_part1.ts": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1, + "/src/third/thirdjs/output/third-output.d.ts": 1 +} + //// [/src/first/bin/first-output.d.ts] interface TheFirst { none: any; diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/triple-slash-refs-in-all-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/triple-slash-refs-in-all-projects.js index 837220d8dd1..25cb88e8ddc 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/triple-slash-refs-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-changes/triple-slash-refs-in-all-projects.js @@ -1,3 +1,45 @@ +//// [/lib/incremental-declaration-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because oldest output 'src/third/thirdjs/output/third-output.js' is older than newest input 'src/first' + +12:04:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/tripleRef.d.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 2, + "/src/2/second-output.tsbuildinfo": 1, + "/src/2/second-output.d.ts": 1, + "/src/second/tripleRef.d.ts": 1, + "/src/third/third_part1.ts": 1, + "/src/third/tripleRef.d.ts": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1, + "/src/third/thirdjs/output/third-output.d.ts": 1 +} + //// [/src/first/bin/first-output.d.ts] /// interface TheFirst { diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/baseline-sectioned-sourcemaps.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/baseline-sectioned-sourcemaps.js index 0c1de645252..e0b14d9a65d 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/baseline-sectioned-sourcemaps.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/baseline-sectioned-sourcemaps.js @@ -1,3 +1,47 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:08:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:08:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:08:00 AM - Building project '/src/first/tsconfig.json'... + +12:08:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:08:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:08:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 1, + "/src/2/second-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.js": 1, + "/src/third/thirdjs/output/third-output.js.map": 1, + "/src/third/thirdjs/output/third-output.d.ts": 1, + "/src/third/thirdjs/output/third-output.d.ts.map": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/2/second-output.d.ts": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1 +} + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] file written with same contents //// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/emitHelpers-in-all-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/emitHelpers-in-all-projects.js index 4049a658d5d..cb0c5eb2bc6 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/emitHelpers-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/emitHelpers-in-all-projects.js @@ -1,3 +1,47 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:08:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:08:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:08:00 AM - Building project '/src/first/tsconfig.json'... + +12:08:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:08:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:08:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 1, + "/src/2/second-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.js": 1, + "/src/third/thirdjs/output/third-output.js.map": 1, + "/src/third/thirdjs/output/third-output.d.ts": 1, + "/src/third/thirdjs/output/third-output.d.ts.map": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/2/second-output.d.ts": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1 +} + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] file written with same contents //// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/emitHelpers-in-only-one-dependency-project.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/emitHelpers-in-only-one-dependency-project.js index 91d63e81d93..11497868243 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/emitHelpers-in-only-one-dependency-project.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/emitHelpers-in-only-one-dependency-project.js @@ -1,3 +1,25 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:04:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] file written with same contents //// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/multiple-emitHelpers-in-all-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/multiple-emitHelpers-in-all-projects.js index 4ea169f5940..d8e06c669bc 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/multiple-emitHelpers-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/multiple-emitHelpers-in-all-projects.js @@ -1,3 +1,25 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:04:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] file written with same contents //// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/multiple-emitHelpers-in-different-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/multiple-emitHelpers-in-different-projects.js index ac94261ec5b..692390e1645 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/multiple-emitHelpers-in-different-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/multiple-emitHelpers-in-different-projects.js @@ -1,3 +1,25 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:04:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] file written with same contents //// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/multiple-prologues-in-all-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/multiple-prologues-in-all-projects.js index a1075353f3e..30075f17e26 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/multiple-prologues-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/multiple-prologues-in-all-projects.js @@ -1,3 +1,47 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:08:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:08:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:08:00 AM - Building project '/src/first/tsconfig.json'... + +12:08:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:08:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:08:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 1, + "/src/2/second-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.js": 1, + "/src/third/thirdjs/output/third-output.js.map": 1, + "/src/third/thirdjs/output/third-output.d.ts": 1, + "/src/third/thirdjs/output/third-output.d.ts.map": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/2/second-output.d.ts": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1 +} + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] file written with same contents //// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/multiple-prologues-in-different-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/multiple-prologues-in-different-projects.js index 75a66a9473f..ba51e272d7e 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/multiple-prologues-in-different-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/multiple-prologues-in-different-projects.js @@ -1,3 +1,25 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:04:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] file written with same contents //// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/shebang-in-all-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/shebang-in-all-projects.js index 66cbcb79b2c..bbddaba06ea 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/shebang-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/shebang-in-all-projects.js @@ -1,3 +1,47 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:08:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:08:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:08:00 AM - Building project '/src/first/tsconfig.json'... + +12:08:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:08:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:08:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 1, + "/src/2/second-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.js": 1, + "/src/third/thirdjs/output/third-output.js.map": 1, + "/src/third/thirdjs/output/third-output.d.ts": 1, + "/src/third/thirdjs/output/third-output.d.ts.map": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1, + "/src/2/second-output.d.ts": 1 +} + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] file written with same contents //// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/shebang-in-only-one-dependency-project.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/shebang-in-only-one-dependency-project.js index 4771fa447ef..8cbabe3c880 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/shebang-in-only-one-dependency-project.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/shebang-in-only-one-dependency-project.js @@ -1,3 +1,25 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:04:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] file written with same contents //// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/strict-in-all-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/strict-in-all-projects.js index 1e7436f9df8..a97bd2a2197 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/strict-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/strict-in-all-projects.js @@ -1,3 +1,47 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:08:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:08:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:08:00 AM - Building project '/src/first/tsconfig.json'... + +12:08:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:08:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:08:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 1, + "/src/2/second-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.js": 1, + "/src/third/thirdjs/output/third-output.js.map": 1, + "/src/third/thirdjs/output/third-output.d.ts": 1, + "/src/third/thirdjs/output/third-output.d.ts.map": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/2/second-output.d.ts": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1 +} + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] file written with same contents //// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/strict-in-one-dependency.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/strict-in-one-dependency.js index 654b18ce483..9bdfad323e9 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/strict-in-one-dependency.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/strict-in-one-dependency.js @@ -1,3 +1,25 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:04:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] file written with same contents //// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js index 6ec1100b4bd..9c369db811c 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js @@ -1,3 +1,29 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:04:00 AM - Updating output of project '/src/second/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/second/tsconfig.json'... + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/second' has changed + +12:04:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.js] var s = "Hello, world"; console.log(s); diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-comment.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-comment.js index a21376924f6..48790653874 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-comment.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-comment.js @@ -1,3 +1,25 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:04:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] file written with same contents //// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js index d68b80c42a4..b7ccf17985a 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js @@ -1,3 +1,29 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:04:00 AM - Updating output of project '/src/second/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/second/tsconfig.json'... + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/second' has changed + +12:04:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.js] var s = "Hello, world"; console.log(s); diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-with-comments-emit-enabled.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-with-comments-emit-enabled.js index b779dcffa53..beb8d35124e 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-with-comments-emit-enabled.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-jsdoc-style-with-comments-emit-enabled.js @@ -1,3 +1,25 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:04:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] file written with same contents //// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-when-one-two-three-are-prepended-in-order.js index f312697a726..e670e22aab6 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-when-one-two-three-are-prepended-in-order.js @@ -1,3 +1,51 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:08:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:08:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:08:00 AM - Building project '/src/first/tsconfig.json'... + +12:08:00 AM - Project 'src/second/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:08:00 AM - Updating output of project '/src/second/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/second/tsconfig.json'... + +12:08:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/second' has changed + +12:08:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 1, + "/src/2/second-output.tsbuildinfo": 2, + "/src/2/second-output.js": 2, + "/src/2/second-output.js.map": 2, + "/src/2/second-output.d.ts": 2, + "/src/2/second-output.d.ts.map": 2, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/third/thirdjs/output/third-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.js": 1, + "/src/third/thirdjs/output/third-output.js.map": 1, + "/src/third/thirdjs/output/third-output.d.ts": 1, + "/src/third/thirdjs/output/third-output.d.ts.map": 1 +} + //// [/src/2/second-output.js] var s = "Hello, world"; console.log(s); diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js index 4ccb69a5a8d..eb1f081ead5 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js @@ -1,3 +1,29 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:04:00 AM - Updating output of project '/src/second/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/second/tsconfig.json'... + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/second' has changed + +12:04:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.js] var s = "Hello, world"; console.log(s); diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-with-comments-emit-enabled.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-with-comments-emit-enabled.js index b64f0367708..51479fbc65d 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-with-comments-emit-enabled.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal-with-comments-emit-enabled.js @@ -1,3 +1,25 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:04:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] file written with same contents //// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal.js index 2fc43e90ec5..4a70c73124e 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/stripInternal.js @@ -1,3 +1,47 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:08:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:08:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:08:00 AM - Building project '/src/first/tsconfig.json'... + +12:08:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:08:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:08:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 1, + "/src/2/second-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.js": 1, + "/src/third/thirdjs/output/third-output.js.map": 1, + "/src/third/thirdjs/output/third-output.d.ts": 1, + "/src/third/thirdjs/output/third-output.d.ts.map": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/2/second-output.d.ts": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1 +} + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] file written with same contents //// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/triple-slash-refs-in-all-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/triple-slash-refs-in-all-projects.js index 0303c231a2d..b11dc0218e2 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/triple-slash-refs-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/triple-slash-refs-in-all-projects.js @@ -1,3 +1,48 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:08:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:08:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:08:00 AM - Building project '/src/first/tsconfig.json'... + +12:08:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:08:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:08:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/tripleRef.d.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 1, + "/src/2/second-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.js": 1, + "/src/third/thirdjs/output/third-output.js.map": 1, + "/src/third/thirdjs/output/third-output.d.ts": 1, + "/src/third/thirdjs/output/third-output.d.ts.map": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/2/second-output.d.ts": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1 +} + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] file written with same contents //// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/triple-slash-refs-in-one-project.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/triple-slash-refs-in-one-project.js index d317b8f29b6..8d9f639e805 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/triple-slash-refs-in-one-project.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/triple-slash-refs-in-one-project.js @@ -1,3 +1,25 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:04:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] file written with same contents //// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/when-final-project-is-not-composite-but-uses-project-references.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/when-final-project-is-not-composite-but-uses-project-references.js index 126759e3719..66e8fed0677 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/when-final-project-is-not-composite-but-uses-project-references.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/when-final-project-is-not-composite-but-uses-project-references.js @@ -1,3 +1,23 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:04:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] file written with same contents //// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/when-source-files-are-empty-in-the-own-file.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/when-source-files-are-empty-in-the-own-file.js index a3b4c95b0f2..c41ea2edc69 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/when-source-files-are-empty-in-the-own-file.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-declaration-doesnt-change/when-source-files-are-empty-in-the-own-file.js @@ -1,3 +1,25 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/third --verbose +12:04:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:04:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:04:00 AM - Building project '/src/first/tsconfig.json'... + +12:04:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:04:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:04:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] file written with same contents //// [/src/first/bin/first-output.d.ts.map.baseline.txt] file written with same contents diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/emitHelpers-in-all-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/emitHelpers-in-all-projects.js index 40ab1fa6dd0..971adc119ac 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/emitHelpers-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/emitHelpers-in-all-projects.js @@ -1,3 +1,47 @@ +//// [/lib/incremental-headers-change-without-dts-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:12:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:12:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:12:00 AM - Building project '/src/first/tsconfig.json'... + +12:12:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:12:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:12:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:12:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 1, + "/src/2/second-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.js": 1, + "/src/third/thirdjs/output/third-output.js.map": 1, + "/src/third/thirdjs/output/third-output.d.ts": 1, + "/src/third/thirdjs/output/third-output.d.ts.map": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/2/second-output.d.ts": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1 +} + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] {"version":3,"file":"first-output.d.ts","sourceRoot":"","sources":["../first_PART1.ts","../first_part2.ts","../first_part3.ts"],"names":[],"mappings":"AAAA,UAAU,QAAQ;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;AAGD,iBAAS,uBAAuB,SAAM;AEXtC,iBAAS,CAAC,WAET"} diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/emitHelpers-in-only-one-dependency-project.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/emitHelpers-in-only-one-dependency-project.js index 95c8bdbb672..4224fc07853 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/emitHelpers-in-only-one-dependency-project.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/emitHelpers-in-only-one-dependency-project.js @@ -1,3 +1,25 @@ +//// [/lib/incremental-headers-change-without-dts-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:08:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:08:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:08:00 AM - Building project '/src/first/tsconfig.json'... + +12:08:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:08:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:08:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] {"version":3,"file":"first-output.d.ts","sourceRoot":"","sources":["../first_PART1.ts","../first_part2.ts","../first_part3.ts"],"names":[],"mappings":"AAAA,UAAU,QAAQ;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;AAGD,iBAAS,uBAAuB,SAE/B;AEbD,iBAAS,CAAC,WAET"} diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/multiple-emitHelpers-in-all-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/multiple-emitHelpers-in-all-projects.js index d5a6f310b95..88807139890 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/multiple-emitHelpers-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/multiple-emitHelpers-in-all-projects.js @@ -1,3 +1,25 @@ +//// [/lib/incremental-headers-change-without-dts-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:08:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:08:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:08:00 AM - Building project '/src/first/tsconfig.json'... + +12:08:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:08:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:08:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] {"version":3,"file":"first-output.d.ts","sourceRoot":"","sources":["../first_PART1.ts","../first_part2.ts","../first_part3.ts"],"names":[],"mappings":"AAAA,UAAU,QAAQ;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;AAGD,iBAAS,uBAAuB,SAAM;AEXtC,iBAAS,CAAC,WAET;AACD,iBAAS,sBAAsB,CAAC,GAAG,GAAG,MAAM,EAAE,QAAK"} diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/multiple-emitHelpers-in-different-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/multiple-emitHelpers-in-different-projects.js index c7426fd026e..2c4350cc261 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/multiple-emitHelpers-in-different-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/multiple-emitHelpers-in-different-projects.js @@ -1,3 +1,25 @@ +//// [/lib/incremental-headers-change-without-dts-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:08:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:08:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:08:00 AM - Building project '/src/first/tsconfig.json'... + +12:08:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:08:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:08:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] {"version":3,"file":"first-output.d.ts","sourceRoot":"","sources":["../first_PART1.ts","../first_part2.ts","../first_part3.ts"],"names":[],"mappings":"AAAA,UAAU,QAAQ;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;AAGD,iBAAS,uBAAuB,SAAM;AEXtC,iBAAS,CAAC,WAET"} diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/multiple-prologues-in-all-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/multiple-prologues-in-all-projects.js index e31929fda61..b7da2a1ff96 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/multiple-prologues-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/multiple-prologues-in-all-projects.js @@ -1,3 +1,47 @@ +//// [/lib/incremental-headers-change-without-dts-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:12:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:12:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:12:00 AM - Building project '/src/first/tsconfig.json'... + +12:12:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:12:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:12:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:12:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 1, + "/src/2/second-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.js": 1, + "/src/third/thirdjs/output/third-output.js.map": 1, + "/src/third/thirdjs/output/third-output.d.ts": 1, + "/src/third/thirdjs/output/third-output.d.ts.map": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/2/second-output.d.ts": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1 +} + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] {"version":3,"file":"first-output.d.ts","sourceRoot":"","sources":["../first_PART1.ts","../first_part2.ts","../first_part3.ts"],"names":[],"mappings":"AAEA,UAAU,QAAQ;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;AEVD,iBAAS,CAAC,WAET"} diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/multiple-prologues-in-different-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/multiple-prologues-in-different-projects.js index 441559cdf45..7b9dc11ca9b 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/multiple-prologues-in-different-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/multiple-prologues-in-different-projects.js @@ -1,3 +1,25 @@ +//// [/lib/incremental-headers-change-without-dts-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:08:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:08:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:08:00 AM - Building project '/src/first/tsconfig.json'... + +12:08:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:08:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:08:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] {"version":3,"file":"first-output.d.ts","sourceRoot":"","sources":["../first_PART1.ts","../first_part2.ts","../first_part3.ts"],"names":[],"mappings":"AACA,UAAU,QAAQ;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;AETD,iBAAS,CAAC,WAET"} diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/strict-in-all-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/strict-in-all-projects.js index 00e04704f80..f762fa7ac29 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/strict-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/strict-in-all-projects.js @@ -1,3 +1,47 @@ +//// [/lib/incremental-headers-change-without-dts-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:12:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:12:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:12:00 AM - Building project '/src/first/tsconfig.json'... + +12:12:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:12:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:12:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:12:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 1, + "/src/2/second-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.js": 1, + "/src/third/thirdjs/output/third-output.js.map": 1, + "/src/third/thirdjs/output/third-output.d.ts": 1, + "/src/third/thirdjs/output/third-output.d.ts.map": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/2/second-output.d.ts": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1 +} + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] {"version":3,"file":"first-output.d.ts","sourceRoot":"","sources":["../first_PART1.ts","../first_part2.ts","../first_part3.ts"],"names":[],"mappings":"AACA,UAAU,QAAQ;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;AETD,iBAAS,CAAC,WAET"} diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/strict-in-one-dependency.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/strict-in-one-dependency.js index 59205be8064..0e8a092a7d1 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/strict-in-one-dependency.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/strict-in-one-dependency.js @@ -1,3 +1,25 @@ +//// [/lib/incremental-headers-change-without-dts-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:08:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:08:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:08:00 AM - Building project '/src/first/tsconfig.json'... + +12:08:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:08:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:08:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] {"version":3,"file":"first-output.d.ts","sourceRoot":"","sources":["../first_PART1.ts","../first_part2.ts","../first_part3.ts"],"names":[],"mappings":"AACA,UAAU,QAAQ;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;AETD,iBAAS,CAAC,WAET"} diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js index 887c845e48b..c4c6dc7ab6d 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js @@ -1,3 +1,29 @@ +//// [/lib/incremental-headers-change-without-dts-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:08:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:08:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:08:00 AM - Building project '/src/first/tsconfig.json'... + +12:08:00 AM - Project 'src/second/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:08:00 AM - Updating output of project '/src/second/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/second/tsconfig.json'... + +12:08:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/second' has changed + +12:08:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts.map] {"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../first/first_PART1.ts","../first/first_part3.ts","../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAA,UAAU,QAAQ;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;ACRD,iBAAS,CAAC,WAET;ACFD,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEM,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;IACF,CAAC,EACM,MAAM;CACnC;AACD,kBAAU,OAAO,CAAC;IACC,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACtD;AACc,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC5C,cAAM,CAAC;IACH,WAAW;CAGd"} diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-jsdoc-style-comment.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-jsdoc-style-comment.js index 3d722243740..44b2e3afe3f 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-jsdoc-style-comment.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-jsdoc-style-comment.js @@ -1,3 +1,25 @@ +//// [/lib/incremental-headers-change-without-dts-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:08:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:08:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:08:00 AM - Building project '/src/first/tsconfig.json'... + +12:08:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:08:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:08:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] {"version":3,"file":"first-output.d.ts","sourceRoot":"","sources":["../first_PART1.ts","../first_part2.ts","../first_part3.ts"],"names":[],"mappings":"AAAA,UAAU,QAAQ;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;AERD,iBAAS,CAAC,WAET"} diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-when-one-two-three-are-prepended-in-order.js index 5f9b856f99c..a157ee39fc9 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-when-one-two-three-are-prepended-in-order.js @@ -1,3 +1,51 @@ +//// [/lib/incremental-headers-change-without-dts-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:12:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:12:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:12:00 AM - Building project '/src/first/tsconfig.json'... + +12:12:00 AM - Project 'src/second/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:12:00 AM - Updating output of project '/src/second/tsconfig.json'... + +12:12:00 AM - Updating unchanged output timestamps of project '/src/second/tsconfig.json'... + +12:12:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/second' has changed + +12:12:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:12:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 1, + "/src/2/second-output.tsbuildinfo": 2, + "/src/2/second-output.js": 2, + "/src/2/second-output.js.map": 2, + "/src/2/second-output.d.ts": 2, + "/src/2/second-output.d.ts.map": 2, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/third/thirdjs/output/third-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.js": 1, + "/src/third/thirdjs/output/third-output.js.map": 1, + "/src/third/thirdjs/output/third-output.d.ts": 1, + "/src/third/thirdjs/output/third-output.d.ts.map": 1 +} + //// [/src/2/second-output.d.ts.map] {"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../first/first_PART1.ts","../first/first_part3.ts","../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAA,UAAU,QAAQ;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;ACRD,iBAAS,CAAC,WAET;ACFD,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEK,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;IACF,CAAC,EACM,MAAM;CAClC;AACD,kBAAU,OAAO,CAAC;IACA,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACrD;AACa,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC3C,cAAM,CAAC;IACH,WAAW;CAGd"} diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js index dcaa317a0d2..fb2071dc256 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js @@ -1,3 +1,29 @@ +//// [/lib/incremental-headers-change-without-dts-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:08:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:08:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:08:00 AM - Building project '/src/first/tsconfig.json'... + +12:08:00 AM - Project 'src/second/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:08:00 AM - Updating output of project '/src/second/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/second/tsconfig.json'... + +12:08:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/second' has changed + +12:08:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts.map] {"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../first/first_PART1.ts","../first/first_part3.ts","../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAA,UAAU,QAAQ;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;ACRD,iBAAS,CAAC,WAET;ACFD,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;AAED,cAAM,OAAO;;IAEK,IAAI,EAAE,MAAM,CAAC;IACb,MAAM;kBACF,CAAC,EACM,MAAM;CAClC;AACD,kBAAU,OAAO,CAAC;IACA,MAAa,CAAC;KAAI;IAClB,SAAgB,GAAG,SAAK;IACxB,UAAiB,aAAa,CAAC;QAAE,MAAa,CAAC;SAAG;KAAE;IACpD,UAAiB,SAAS,CAAC,SAAS,CAAC;QAAE,MAAa,SAAS;SAAG;KAAE;IAClE,MAAM,QAAQ,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC;IAC3C,KAAY,YAAY,GAAG,SAAS,CAAC;IAC9B,MAAM,aAAa,KAAK,CAAC;IAChC,KAAY,YAAY;QAAG,CAAC,IAAA;QAAE,CAAC,IAAA;QAAE,CAAC,IAAA;KAAE;CACrD;AACa,cAAM,SAAS;CAAG;AAClB,iBAAS,WAAW,SAAK;AACzB,kBAAU,iBAAiB,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AACzD,kBAAU,aAAa,CAAC,SAAS,CAAC;IAAE,MAAa,SAAS;KAAG;CAAE;AAC/D,OAAO,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpD,aAAK,YAAY,GAAG,SAAS,CAAC;AAC9B,QAAA,MAAM,aAAa,KAAK,CAAC;AACzB,aAAK,YAAY;IAAG,CAAC,IAAA;IAAE,CAAC,IAAA;IAAE,CAAC,IAAA;CAAE;ACpC3C,cAAM,CAAC;IACH,WAAW;CAGd"} diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-with-comments-emit-enabled.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-with-comments-emit-enabled.js index 93681166f46..a4a3c13a5f4 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-with-comments-emit-enabled.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-with-comments-emit-enabled.js @@ -1,3 +1,25 @@ +//// [/lib/incremental-headers-change-without-dts-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:08:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:08:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:08:00 AM - Building project '/src/first/tsconfig.json'... + +12:08:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:08:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:08:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] {"version":3,"file":"first-output.d.ts","sourceRoot":"","sources":["../first_PART1.ts","../first_part2.ts","../first_part3.ts"],"names":[],"mappings":"AAAA,UAAU,QAAQ;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;AERD,iBAAS,CAAC,WAET"} diff --git a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal.js b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal.js index 832ea5e5de0..a048c6ecd75 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal.js @@ -1,3 +1,47 @@ +//// [/lib/incremental-headers-change-without-dts-changesOutput.txt] +/lib/tsc --b /src/third --verbose +12:12:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:12:00 AM - Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.js' is older than newest input 'src/first/first_PART1.ts' + +12:12:00 AM - Building project '/src/first/tsconfig.json'... + +12:12:00 AM - Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.js' + +12:12:00 AM - Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed + +12:12:00 AM - Updating output of project '/src/third/tsconfig.json'... + +12:12:00 AM - Updating unchanged output timestamps of project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 1, + "/src/2/second-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.tsbuildinfo": 1, + "/src/third/thirdjs/output/third-output.js": 1, + "/src/third/thirdjs/output/third-output.js.map": 1, + "/src/third/thirdjs/output/third-output.d.ts": 1, + "/src/third/thirdjs/output/third-output.d.ts.map": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/2/second-output.d.ts": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1 +} + //// [/src/first/bin/first-output.d.ts] file written with same contents //// [/src/first/bin/first-output.d.ts.map] {"version":3,"file":"first-output.d.ts","sourceRoot":"","sources":["../first_PART1.ts","../first_part2.ts","../first_part3.ts"],"names":[],"mappings":"AAAA,UAAU,QAAQ;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;AERD,iBAAS,CAAC,WAET"} diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/baseline-sectioned-sourcemaps.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/baseline-sectioned-sourcemaps.js similarity index 93% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/baseline-sectioned-sourcemaps.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/baseline-sectioned-sourcemaps.js index dc954db7140..2b217d8a1d1 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/baseline-sectioned-sourcemaps.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/baseline-sectioned-sourcemaps.js @@ -1,3 +1,45 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/second/second_part1.ts": 1, + "/src/second/second_part2.ts": 1, + "/src/first/bin/first-output.d.ts": 1, + "/src/2/second-output.d.ts": 1, + "/src/third/third_part1.ts": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/2/second-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1 +} + //// [/src/2/second-output.d.ts] declare namespace N { } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/declarationMap-and-sourceMap-disabled.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/declarationMap-and-sourceMap-disabled.js similarity index 93% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/declarationMap-and-sourceMap-disabled.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/declarationMap-and-sourceMap-disabled.js index 71e66236a0a..41e8f94b4aa 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/declarationMap-and-sourceMap-disabled.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/declarationMap-and-sourceMap-disabled.js @@ -1,3 +1,25 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:00:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:00:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:00:00 AM - Building project '/src/first/tsconfig.json'... + +12:00:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:00:00 AM - Building project '/src/second/tsconfig.json'... + +12:00:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:00:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts] declare namespace N { } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/emitHelpers-in-all-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/emitHelpers-in-all-projects.js similarity index 94% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/emitHelpers-in-all-projects.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/emitHelpers-in-all-projects.js index f005ab7855c..7dbec0f66cf 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/emitHelpers-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/emitHelpers-in-all-projects.js @@ -1,3 +1,45 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/second/second_part1.ts": 1, + "/src/second/second_part2.ts": 1, + "/src/first/bin/first-output.d.ts": 1, + "/src/2/second-output.d.ts": 1, + "/src/third/third_part1.ts": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/2/second-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1 +} + //// [/src/2/second-output.d.ts] declare namespace N { } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/emitHelpers-in-only-one-dependency-project.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/emitHelpers-in-only-one-dependency-project.js similarity index 95% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/emitHelpers-in-only-one-dependency-project.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/emitHelpers-in-only-one-dependency-project.js index a0903bec835..b946940addd 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/emitHelpers-in-only-one-dependency-project.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/emitHelpers-in-only-one-dependency-project.js @@ -1,3 +1,25 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts] declare namespace N { } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/multiple-emitHelpers-in-all-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/multiple-emitHelpers-in-all-projects.js similarity index 96% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/multiple-emitHelpers-in-all-projects.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/multiple-emitHelpers-in-all-projects.js index c9c46a61769..242690d2885 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/multiple-emitHelpers-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/multiple-emitHelpers-in-all-projects.js @@ -1,3 +1,25 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts] declare namespace N { } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/multiple-emitHelpers-in-different-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/multiple-emitHelpers-in-different-projects.js similarity index 95% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/multiple-emitHelpers-in-different-projects.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/multiple-emitHelpers-in-different-projects.js index a5a8082cb6e..93ba9fcc3e3 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/multiple-emitHelpers-in-different-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/multiple-emitHelpers-in-different-projects.js @@ -1,3 +1,25 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts] declare namespace N { } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/multiple-prologues-in-all-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/multiple-prologues-in-all-projects.js similarity index 94% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/multiple-prologues-in-all-projects.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/multiple-prologues-in-all-projects.js index 9f1174ea545..21f8943ae6b 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/multiple-prologues-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/multiple-prologues-in-all-projects.js @@ -1,3 +1,45 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/second/second_part1.ts": 1, + "/src/second/second_part2.ts": 1, + "/src/first/bin/first-output.d.ts": 1, + "/src/2/second-output.d.ts": 1, + "/src/third/third_part1.ts": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/2/second-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1 +} + //// [/src/2/second-output.d.ts] declare namespace N { } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/multiple-prologues-in-different-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/multiple-prologues-in-different-projects.js similarity index 95% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/multiple-prologues-in-different-projects.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/multiple-prologues-in-different-projects.js index ccd01c44d76..ea725d85d49 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/multiple-prologues-in-different-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/multiple-prologues-in-different-projects.js @@ -1,3 +1,25 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts] declare namespace N { } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/shebang-in-all-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/shebang-in-all-projects.js similarity index 93% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/shebang-in-all-projects.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/shebang-in-all-projects.js index 8a9eddef3eb..b8adefd8976 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/shebang-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/shebang-in-all-projects.js @@ -1,3 +1,45 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/second/second_part1.ts": 1, + "/src/second/second_part2.ts": 1, + "/src/first/bin/first-output.d.ts": 1, + "/src/2/second-output.d.ts": 1, + "/src/third/third_part1.ts": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/2/second-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1 +} + //// [/src/2/second-output.d.ts] #!someshebang second second_part1 declare namespace N { diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/shebang-in-only-one-dependency-project.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/shebang-in-only-one-dependency-project.js similarity index 94% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/shebang-in-only-one-dependency-project.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/shebang-in-only-one-dependency-project.js index 6238d669fd9..bab82334961 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/shebang-in-only-one-dependency-project.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/shebang-in-only-one-dependency-project.js @@ -1,3 +1,25 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts] #!someshebang second second_part1 declare namespace N { diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/strict-in-all-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/strict-in-all-projects.js similarity index 93% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/strict-in-all-projects.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/strict-in-all-projects.js index a87a175f3f6..1471bdb3090 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/strict-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/strict-in-all-projects.js @@ -1,3 +1,45 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/second/second_part1.ts": 1, + "/src/second/second_part2.ts": 1, + "/src/first/bin/first-output.d.ts": 1, + "/src/2/second-output.d.ts": 1, + "/src/third/third_part1.ts": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/2/second-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1 +} + //// [/src/2/second-output.d.ts] declare namespace N { } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/strict-in-one-dependency.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/strict-in-one-dependency.js similarity index 95% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/strict-in-one-dependency.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/strict-in-one-dependency.js index 5ad6a0c4742..8a4cce33dfc 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/strict-in-one-dependency.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/strict-in-one-dependency.js @@ -1,3 +1,25 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts] declare namespace N { } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-baseline-when-internal-is-inside-another-internal.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-baseline-when-internal-is-inside-another-internal.js similarity index 95% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-baseline-when-internal-is-inside-another-internal.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-baseline-when-internal-is-inside-another-internal.js index 8d6722f4b78..5595b32ed57 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-baseline-when-internal-is-inside-another-internal.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-baseline-when-internal-is-inside-another-internal.js @@ -1,3 +1,25 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:00:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:00:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:00:00 AM - Building project '/src/first/tsconfig.json'... + +12:00:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:00:00 AM - Building project '/src/second/tsconfig.json'... + +12:00:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:00:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts] declare namespace N { } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js similarity index 96% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js index 7a5d6f628ed..c341d9c5d22 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js @@ -1,3 +1,25 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts] interface TheFirst { none: any; diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-jsdoc-style-comment.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment.js similarity index 96% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-jsdoc-style-comment.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment.js index 6e4cd6c0d26..709634ade27 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-jsdoc-style-comment.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment.js @@ -1,3 +1,25 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts] declare namespace N { } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js similarity index 96% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js index 0890b8d8188..81653bf15bb 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js @@ -1,3 +1,25 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts] /**@internal*/ interface TheFirst { none: any; diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-jsdoc-style-with-comments-emit-enabled.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled.js similarity index 96% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-jsdoc-style-with-comments-emit-enabled.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled.js index 87badd92039..e86999f7bf4 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-jsdoc-style-with-comments-emit-enabled.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled.js @@ -1,3 +1,25 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts] declare namespace N { } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-when-few-members-of-enum-are-internal.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-when-few-members-of-enum-are-internal.js similarity index 96% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-when-few-members-of-enum-are-internal.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-when-few-members-of-enum-are-internal.js index 91558992f04..91cf996eddd 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-when-few-members-of-enum-are-internal.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-when-few-members-of-enum-are-internal.js @@ -1,3 +1,25 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:00:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:00:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:00:00 AM - Building project '/src/first/tsconfig.json'... + +12:00:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:00:00 AM - Building project '/src/second/tsconfig.json'... + +12:00:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:00:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts] declare namespace N { } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-when-one-two-three-are-prepended-in-order.js similarity index 96% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-when-one-two-three-are-prepended-in-order.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-when-one-two-three-are-prepended-in-order.js index 89862863170..a858a1e27d8 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-when-one-two-three-are-prepended-in-order.js @@ -1,3 +1,45 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/first/bin/first-output.d.ts": 1, + "/src/second/second_part1.ts": 1, + "/src/second/second_part2.ts": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts": 1, + "/src/third/third_part1.ts": 1, + "/src/2/second-output.tsbuildinfo": 1, + "/src/2/second-output.js": 1, + "/src/2/second-output.js.map": 1, + "/src/2/second-output.d.ts.map": 1 +} + //// [/src/2/second-output.d.ts] interface TheFirst { none: any; diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js similarity index 96% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js index 5d2941abca2..fa4c05b80fe 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js @@ -1,3 +1,25 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts] interface TheFirst { none: any; diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-with-comments-emit-enabled.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled.js similarity index 96% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-with-comments-emit-enabled.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled.js index 2475d4e4eda..d6818122891 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal-with-comments-emit-enabled.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled.js @@ -1,3 +1,25 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts] declare namespace N { } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal.js similarity index 96% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal.js index 7ac42063f7d..0f0cf474ca7 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/stripInternal.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal.js @@ -1,3 +1,45 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/second/second_part1.ts": 1, + "/src/second/second_part2.ts": 1, + "/src/first/bin/first-output.d.ts": 1, + "/src/2/second-output.d.ts": 1, + "/src/third/third_part1.ts": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/2/second-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1 +} + //// [/src/2/second-output.d.ts] declare namespace N { } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/triple-slash-refs-in-all-projects.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/triple-slash-refs-in-all-projects.js similarity index 94% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/triple-slash-refs-in-all-projects.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/triple-slash-refs-in-all-projects.js index 9310b004ec3..c8efbd205e6 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/triple-slash-refs-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/triple-slash-refs-in-all-projects.js @@ -1,3 +1,48 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/third/tsconfig.json": 1, + "/src/first/tsconfig.json": 1, + "/src/second/tsconfig.json": 1, + "/src/first/first_PART1.ts": 1, + "/src/first/first_part2.ts": 1, + "/src/first/tripleRef.d.ts": 1, + "/src/first/first_part3.ts": 1, + "/src/second/second_part1.ts": 1, + "/src/second/tripleRef.d.ts": 1, + "/src/second/second_part2.ts": 1, + "/src/first/bin/first-output.d.ts": 1, + "/src/2/second-output.d.ts": 1, + "/src/third/third_part1.ts": 1, + "/src/third/tripleRef.d.ts": 1, + "/src/first/bin/first-output.tsbuildinfo": 1, + "/src/2/second-output.tsbuildinfo": 1, + "/src/first/bin/first-output.js": 1, + "/src/2/second-output.js": 1, + "/src/first/bin/first-output.js.map": 1, + "/src/2/second-output.js.map": 1, + "/src/first/bin/first-output.d.ts.map": 1, + "/src/2/second-output.d.ts.map": 1 +} + //// [/src/2/second-output.d.ts] /// declare const second_part1Const: secondsecond_part1; diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/triple-slash-refs-in-one-project.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/triple-slash-refs-in-one-project.js similarity index 95% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/triple-slash-refs-in-one-project.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/triple-slash-refs-in-one-project.js index 9a0bc722742..471309f35f0 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/triple-slash-refs-in-one-project.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/triple-slash-refs-in-one-project.js @@ -1,3 +1,25 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts] /// declare const second_part1Const: secondsecond_part1; diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/when-final-project-is-not-composite-but-incremental.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/when-final-project-is-not-composite-but-incremental.js similarity index 94% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/when-final-project-is-not-composite-but-incremental.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/when-final-project-is-not-composite-but-incremental.js index 77755214958..81bec95d4f6 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/when-final-project-is-not-composite-but-incremental.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/when-final-project-is-not-composite-but-incremental.js @@ -1,3 +1,25 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:00:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:00:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:00:00 AM - Building project '/src/first/tsconfig.json'... + +12:00:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:00:00 AM - Building project '/src/second/tsconfig.json'... + +12:00:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:00:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts] declare namespace N { } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/when-final-project-is-not-composite-but-uses-project-references.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/when-final-project-is-not-composite-but-uses-project-references.js similarity index 94% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/when-final-project-is-not-composite-but-uses-project-references.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/when-final-project-is-not-composite-but-uses-project-references.js index 2564a1ae67e..2e7b1f1663f 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/when-final-project-is-not-composite-but-uses-project-references.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/when-final-project-is-not-composite-but-uses-project-references.js @@ -1,3 +1,25 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts] declare namespace N { } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/when-final-project-specifies-tsBuildInfoFile.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/when-final-project-specifies-tsBuildInfoFile.js similarity index 94% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/when-final-project-specifies-tsBuildInfoFile.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/when-final-project-specifies-tsBuildInfoFile.js index 288f507f70b..b0131b6af56 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/when-final-project-specifies-tsBuildInfoFile.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/when-final-project-specifies-tsBuildInfoFile.js @@ -1,3 +1,25 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:00:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:00:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:00:00 AM - Building project '/src/first/tsconfig.json'... + +12:00:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:00:00 AM - Building project '/src/second/tsconfig.json'... + +12:00:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:00:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts] declare namespace N { } diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/when-source-files-are-empty-in-the-own-file.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/when-source-files-are-empty-in-the-own-file.js similarity index 94% rename from tests/baselines/reference/tsbuild/outfile-concat/initial-Build/when-source-files-are-empty-in-the-own-file.js rename to tests/baselines/reference/tsbuild/outfile-concat/initial-build/when-source-files-are-empty-in-the-own-file.js index 7269a7ca744..deb7dbd86e6 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-Build/when-source-files-are-empty-in-the-own-file.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/when-source-files-are-empty-in-the-own-file.js @@ -1,3 +1,25 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/third --verbose +12:01:00 AM - Projects in this build: + * src/first/tsconfig.json + * src/second/tsconfig.json + * src/third/tsconfig.json + +12:01:00 AM - Project 'src/first/tsconfig.json' is out of date because output file 'src/first/bin/first-output.js' does not exist + +12:01:00 AM - Building project '/src/first/tsconfig.json'... + +12:01:00 AM - Project 'src/second/tsconfig.json' is out of date because output file 'src/2/second-output.js' does not exist + +12:01:00 AM - Building project '/src/second/tsconfig.json'... + +12:01:00 AM - Project 'src/third/tsconfig.json' is out of date because output file 'src/third/thirdjs/output/third-output.js' does not exist + +12:01:00 AM - Building project '/src/third/tsconfig.json'... + +exitCode:: 0 + + //// [/src/2/second-output.d.ts] declare namespace N { } diff --git a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/sample.js b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/sample.js index 0a2ce56cb64..94a962ebe02 100644 --- a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/sample.js +++ b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/sample.js @@ -1,3 +1,43 @@ +//// [/lib/incremental-declaration-changesOutput.txt] +/lib/tsc --b /src/tests --verbose +12:04:00 AM - Projects in this build: + * src/core/tsconfig.json + * src/logic/tsconfig.json + * src/tests/tsconfig.json + +12:04:00 AM - Project 'src/core/tsconfig.json' is out of date because oldest output 'src/core/anotherModule.js' is older than newest input 'src/core/index.ts' + +12:04:00 AM - Building project '/src/core/tsconfig.json'... + +12:04:00 AM - Updating unchanged output timestamps of project '/src/core/tsconfig.json'... + +12:04:00 AM - Project 'src/logic/tsconfig.json' is out of date because oldest output 'src/logic/index.js' is older than newest input 'src/core' + +12:04:00 AM - Building project '/src/logic/tsconfig.json'... + +12:04:00 AM - Project 'src/tests/tsconfig.json' is out of date because oldest output 'src/tests/index.js' is older than newest input 'src/core' + +12:04:00 AM - Building project '/src/tests/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/tests/tsconfig.json": 1, + "/src/core/tsconfig.json": 1, + "/src/logic/tsconfig.json": 1, + "/src/core/tsconfig.tsbuildinfo": 1, + "/src/core/anotherModule.ts": 1, + "/src/core/index.ts": 1, + "/src/core/some_decl.d.ts": 1, + "/src/core/index.d.ts": 2, + "/src/logic/tsconfig.tsbuildinfo": 1, + "/src/logic/index.ts": 1, + "/src/core/anotherModule.d.ts": 1, + "/src/logic/index.d.ts": 1, + "/src/tests/tsconfig.tsbuildinfo": 1, + "/src/tests/index.ts": 1, + "/src/tests/index.d.ts": 1 +} + //// [/src/core/index.d.ts] export declare const someString: string; export declare function leftPad(s: string, n: number): string; diff --git a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-declaration-option-changes.js b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-declaration-option-changes.js index b3c22649712..2311e64ef2b 100644 --- a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-declaration-option-changes.js +++ b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-declaration-option-changes.js @@ -1,3 +1,15 @@ +//// [/lib/incremental-declaration-changesOutput.txt] +/lib/tsc --b /src/core --verbose +12:04:00 AM - Projects in this build: + * src/core/tsconfig.json + +12:04:00 AM - Project 'src/core/tsconfig.json' is out of date because output file 'src/core/anotherModule.d.ts' does not exist + +12:04:00 AM - Building project '/src/core/tsconfig.json'... + +exitCode:: 0 + + //// [/src/core/anotherModule.d.ts] export declare const World = "hello"; diff --git a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-esModuleInterop-option-changes.js b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-esModuleInterop-option-changes.js index a701b09575a..dd48841c8af 100644 --- a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-esModuleInterop-option-changes.js +++ b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-esModuleInterop-option-changes.js @@ -1,3 +1,21 @@ +//// [/lib/incremental-declaration-changesOutput.txt] +/lib/tsc --b /src/tests --verbose +12:04:00 AM - Projects in this build: + * src/core/tsconfig.json + * src/logic/tsconfig.json + * src/tests/tsconfig.json + +12:04:00 AM - Project 'src/core/tsconfig.json' is up to date because newest input 'src/core/anotherModule.ts' is older than oldest output 'src/core/anotherModule.js' + +12:04:00 AM - Project 'src/logic/tsconfig.json' is up to date because newest input 'src/logic/index.ts' is older than oldest output 'src/logic/index.js' + +12:04:00 AM - Project 'src/tests/tsconfig.json' is out of date because oldest output 'src/tests/index.js' is older than newest input 'src/tests/tsconfig.json' + +12:04:00 AM - Building project '/src/tests/tsconfig.json'... + +exitCode:: 0 + + //// [/src/tests/index.d.ts] file written with same contents //// [/src/tests/index.js] "use strict"; diff --git a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-logic-config-changes-declaration-dir.js b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-logic-config-changes-declaration-dir.js index 701737ec3b5..da943e101e2 100644 --- a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-logic-config-changes-declaration-dir.js +++ b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-logic-config-changes-declaration-dir.js @@ -1,3 +1,36 @@ +//// [/lib/incremental-declaration-changesOutput.txt] +/lib/tsc --b /src/tests --verbose +12:12:00 AM - Projects in this build: + * src/core/tsconfig.json + * src/logic/tsconfig.json + * src/tests/tsconfig.json + +12:12:00 AM - Project 'src/core/tsconfig.json' is up to date because newest input 'src/core/anotherModule.ts' is older than oldest output 'src/core/anotherModule.js' + +12:12:00 AM - Project 'src/logic/tsconfig.json' is out of date because output file 'src/logic/decls/index.d.ts' does not exist + +12:12:00 AM - Building project '/src/logic/tsconfig.json'... + +12:12:00 AM - Project 'src/tests/tsconfig.json' is out of date because oldest output 'src/tests/index.js' is older than newest input 'src/logic' + +12:12:00 AM - Building project '/src/tests/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/tests/tsconfig.json": 1, + "/src/core/tsconfig.json": 1, + "/src/logic/tsconfig.json": 1, + "/src/core/tsconfig.tsbuildinfo": 1, + "/src/logic/tsconfig.tsbuildinfo": 1, + "/src/logic/index.ts": 1, + "/src/core/index.d.ts": 1, + "/src/core/anotherModule.d.ts": 1, + "/src/tests/tsconfig.tsbuildinfo": 1, + "/src/tests/index.ts": 1, + "/src/logic/decls/index.d.ts": 1, + "/src/tests/index.d.ts": 1 +} + //// [/src/logic/decls/index.d.ts] export declare function getSecondsInDay(): number; import * as mod from '../core/anotherModule'; diff --git a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-module-option-changes.js b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-module-option-changes.js index d6c6fb4d877..0a801843705 100644 --- a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-module-option-changes.js +++ b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-module-option-changes.js @@ -1,3 +1,15 @@ +//// [/lib/incremental-declaration-changesOutput.txt] +/lib/tsc --b /src/core --verbose +12:04:00 AM - Projects in this build: + * src/core/tsconfig.json + +12:04:00 AM - Project 'src/core/tsconfig.json' is out of date because oldest output 'src/core/anotherModule.js' is older than newest input 'src/core/tsconfig.json' + +12:04:00 AM - Building project '/src/core/tsconfig.json'... + +exitCode:: 0 + + //// [/src/core/anotherModule.js] define(["require", "exports"], function (require, exports) { "use strict"; diff --git a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-target-option-changes.js b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-target-option-changes.js index 0dc8156158d..bc3a7921993 100644 --- a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-target-option-changes.js +++ b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-target-option-changes.js @@ -1,3 +1,23 @@ +//// [/lib/incremental-declaration-changesOutput.txt] +/lib/tsc --b /src/core --verbose +12:04:00 AM - Projects in this build: + * src/core/tsconfig.json + +12:04:00 AM - Project 'src/core/tsconfig.json' is out of date because oldest output 'src/core/anotherModule.js' is older than newest input 'src/core/tsconfig.json' + +12:04:00 AM - Building project '/src/core/tsconfig.json'... + +TSFILE: /src/core/anotherModule.js +TSFILE: /src/core/index.js +TSFILE: /src/core/tsconfig.tsbuildinfo +/lib/lib.d.ts +/lib/lib.esnext.d.ts +/src/core/anotherModule.ts +/src/core/index.ts +/src/core/some_decl.d.ts +exitCode:: 0 + + //// [/src/core/anotherModule.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-doesnt-change/sample.js b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-doesnt-change/sample.js index 658377ce3a3..a2d9e5a8564 100644 --- a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-doesnt-change/sample.js +++ b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-doesnt-change/sample.js @@ -1,3 +1,38 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/tests --verbose +12:08:00 AM - Projects in this build: + * src/core/tsconfig.json + * src/logic/tsconfig.json + * src/tests/tsconfig.json + +12:08:00 AM - Project 'src/core/tsconfig.json' is out of date because oldest output 'src/core/anotherModule.js' is older than newest input 'src/core/index.ts' + +12:08:00 AM - Building project '/src/core/tsconfig.json'... + +12:08:00 AM - Updating unchanged output timestamps of project '/src/core/tsconfig.json'... + +12:08:00 AM - Project 'src/logic/tsconfig.json' is up to date with .d.ts files from its dependencies + +12:08:00 AM - Updating output timestamps of project '/src/logic/tsconfig.json'... + +12:08:00 AM - Project 'src/tests/tsconfig.json' is up to date with .d.ts files from its dependencies + +12:08:00 AM - Updating output timestamps of project '/src/tests/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/tests/tsconfig.json": 1, + "/src/core/tsconfig.json": 1, + "/src/logic/tsconfig.json": 1, + "/src/core/tsconfig.tsbuildinfo": 1, + "/src/core/anotherModule.ts": 1, + "/src/core/index.ts": 1, + "/src/core/some_decl.d.ts": 1, + "/src/core/index.d.ts": 1, + "/src/logic/tsconfig.tsbuildinfo": 1, + "/src/tests/tsconfig.tsbuildinfo": 1 +} + //// [/src/core/index.d.ts] file written with same contents //// [/src/core/index.d.ts.map] file written with same contents //// [/src/core/index.d.ts.map.baseline.txt] file written with same contents diff --git a/tests/baselines/reference/tsbuild/sample1/initial-Build/when-logic-config-changes-declaration-dir.js b/tests/baselines/reference/tsbuild/sample1/initial-Build/when-logic-config-changes-declaration-dir.js deleted file mode 100644 index 7a9f9a2ea95..00000000000 --- a/tests/baselines/reference/tsbuild/sample1/initial-Build/when-logic-config-changes-declaration-dir.js +++ /dev/null @@ -1,494 +0,0 @@ -//// [/src/core/anotherModule.d.ts] -export declare const World = "hello"; -//# sourceMappingURL=anotherModule.d.ts.map - -//// [/src/core/anotherModule.d.ts.map] -{"version":3,"file":"anotherModule.d.ts","sourceRoot":"","sources":["anotherModule.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,UAAU,CAAC"} - -//// [/src/core/anotherModule.d.ts.map.baseline.txt] -=================================================================== -JsFile: anotherModule.d.ts -mapUrl: anotherModule.d.ts.map -sourceRoot: -sources: anotherModule.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:/src/core/anotherModule.d.ts -sourceFile:anotherModule.ts -------------------------------------------------------------------- ->>>export declare const World = "hello"; -1 > -2 >^^^^^^^^^^^^^^^ -3 > ^^^^^^ -4 > ^^^^^ -5 > ^^^^^^^^^^ -6 > ^ -7 > ^^^^^-> -1 > -2 >export -3 > const -4 > World -5 > = "hello" -6 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 16) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 22) Source(1, 14) + SourceIndex(0) -4 >Emitted(1, 27) Source(1, 19) + SourceIndex(0) -5 >Emitted(1, 37) Source(1, 29) + SourceIndex(0) -6 >Emitted(1, 38) Source(1, 30) + SourceIndex(0) ---- ->>>//# sourceMappingURL=anotherModule.d.ts.map - -//// [/src/core/anotherModule.js] -"use strict"; -exports.__esModule = true; -exports.World = "hello"; - - -//// [/src/core/index.d.ts] -export declare const someString: string; -export declare function leftPad(s: string, n: number): string; -export declare function multiply(a: number, b: number): number; -//# sourceMappingURL=index.d.ts.map - -//// [/src/core/index.d.ts.map] -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,EAAE,MAAsB,CAAC;AAChD,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,UAAmB;AAC/D,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,UAAmB"} - -//// [/src/core/index.d.ts.map.baseline.txt] -=================================================================== -JsFile: index.d.ts -mapUrl: index.d.ts.map -sourceRoot: -sources: index.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:/src/core/index.d.ts -sourceFile:index.ts -------------------------------------------------------------------- ->>>export declare const someString: string; -1 > -2 >^^^^^^^^^^^^^^^ -3 > ^^^^^^ -4 > ^^^^^^^^^^ -5 > ^^ -6 > ^^^^^^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -2 >export -3 > const -4 > someString -5 > : -6 > string = "HELLO WORLD" -7 > ; -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 16) Source(1, 8) + SourceIndex(0) -3 >Emitted(1, 22) Source(1, 14) + SourceIndex(0) -4 >Emitted(1, 32) Source(1, 24) + SourceIndex(0) -5 >Emitted(1, 34) Source(1, 26) + SourceIndex(0) -6 >Emitted(1, 40) Source(1, 48) + SourceIndex(0) -7 >Emitted(1, 41) Source(1, 49) + SourceIndex(0) ---- ->>>export declare function leftPad(s: string, n: number): string; -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^ -4 > ^ -5 > ^ -6 > ^^ -7 > ^^^^^^ -8 > ^^ -9 > ^ -10> ^^ -11> ^^^^^^ -12> ^^^^^^^^^^ -13> ^^-> -1-> - > -2 >export function -3 > leftPad -4 > ( -5 > s -6 > : -7 > string -8 > , -9 > n -10> : -11> number -12> ) { return s + n; } -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(2, 25) Source(2, 17) + SourceIndex(0) -3 >Emitted(2, 32) Source(2, 24) + SourceIndex(0) -4 >Emitted(2, 33) Source(2, 25) + SourceIndex(0) -5 >Emitted(2, 34) Source(2, 26) + SourceIndex(0) -6 >Emitted(2, 36) Source(2, 28) + SourceIndex(0) -7 >Emitted(2, 42) Source(2, 34) + SourceIndex(0) -8 >Emitted(2, 44) Source(2, 36) + SourceIndex(0) -9 >Emitted(2, 45) Source(2, 37) + SourceIndex(0) -10>Emitted(2, 47) Source(2, 39) + SourceIndex(0) -11>Emitted(2, 53) Source(2, 45) + SourceIndex(0) -12>Emitted(2, 63) Source(2, 64) + SourceIndex(0) ---- ->>>export declare function multiply(a: number, b: number): number; -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^ -5 > ^ -6 > ^^ -7 > ^^^^^^ -8 > ^^ -9 > ^ -10> ^^ -11> ^^^^^^ -12> ^^^^^^^^^^ -1-> - > -2 >export function -3 > multiply -4 > ( -5 > a -6 > : -7 > number -8 > , -9 > b -10> : -11> number -12> ) { return a * b; } -1->Emitted(3, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(3, 25) Source(3, 17) + SourceIndex(0) -3 >Emitted(3, 33) Source(3, 25) + SourceIndex(0) -4 >Emitted(3, 34) Source(3, 26) + SourceIndex(0) -5 >Emitted(3, 35) Source(3, 27) + SourceIndex(0) -6 >Emitted(3, 37) Source(3, 29) + SourceIndex(0) -7 >Emitted(3, 43) Source(3, 35) + SourceIndex(0) -8 >Emitted(3, 45) Source(3, 37) + SourceIndex(0) -9 >Emitted(3, 46) Source(3, 38) + SourceIndex(0) -10>Emitted(3, 48) Source(3, 40) + SourceIndex(0) -11>Emitted(3, 54) Source(3, 46) + SourceIndex(0) -12>Emitted(3, 64) Source(3, 65) + SourceIndex(0) ---- ->>>//# sourceMappingURL=index.d.ts.map - -//// [/src/core/index.js] -"use strict"; -exports.__esModule = true; -exports.someString = "HELLO WORLD"; -function leftPad(s, n) { return s + n; } -exports.leftPad = leftPad; -function multiply(a, b) { return a * b; } -exports.multiply = multiply; - - -//// [/src/core/tsconfig.tsbuildinfo] -{ - "program": { - "fileInfos": { - "../../lib/lib.d.ts": { - "version": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", - "signature": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };" - }, - "./anothermodule.ts": { - "version": "-2676574883-export const World = \"hello\";\r\n", - "signature": "7652028357-export declare const World = \"hello\";\r\n//# sourceMappingURL=anotherModule.d.ts.map" - }, - "./index.ts": { - "version": "-18749805970-export const someString: string = \"HELLO WORLD\";\r\nexport function leftPad(s: string, n: number) { return s + n; }\r\nexport function multiply(a: number, b: number) { return a * b; }\r\n", - "signature": "-13851440507-export declare const someString: string;\r\nexport declare function leftPad(s: string, n: number): string;\r\nexport declare function multiply(a: number, b: number): number;\r\n//# sourceMappingURL=index.d.ts.map" - }, - "./some_decl.d.ts": { - "version": "-9253692965-declare const dts: any;\r\n", - "signature": "-9253692965-declare const dts: any;\r\n" - } - }, - "options": { - "composite": true, - "declaration": true, - "declarationMap": true, - "skipDefaultLibCheck": true, - "configFilePath": "./tsconfig.json" - }, - "referencedMap": {}, - "exportedModulesMap": {}, - "semanticDiagnosticsPerFile": [ - "../../lib/lib.d.ts", - "./anothermodule.ts", - "./index.ts", - "./some_decl.d.ts" - ] - }, - "version": "FakeTSVersion" -} - -//// [/src/logic/index.d.ts] -export declare function getSecondsInDay(): number; -import * as mod from '../core/anotherModule'; -export declare const m: typeof mod; - - -//// [/src/logic/index.js] -"use strict"; -exports.__esModule = true; -var c = require("../core/index"); -function getSecondsInDay() { - return c.multiply(10, 15); -} -exports.getSecondsInDay = getSecondsInDay; -var mod = require("../core/anotherModule"); -exports.m = mod; -//# sourceMappingURL=index.js.map - -//// [/src/logic/index.js.map] -{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAAA,iCAAmC;AACnC,SAAgB,eAAe;IAC3B,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC9B,CAAC;AAFD,0CAEC;AACD,2CAA6C;AAChC,QAAA,CAAC,GAAG,GAAG,CAAC"} - -//// [/src/logic/index.js.map.baseline.txt] -=================================================================== -JsFile: index.js -mapUrl: index.js.map -sourceRoot: -sources: index.ts -=================================================================== -------------------------------------------------------------------- -emittedFile:/src/logic/index.js -sourceFile:index.ts -------------------------------------------------------------------- ->>>"use strict"; ->>>exports.__esModule = true; ->>>var c = require("../core/index"); -1 > -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1 > -2 >import * as c from '../core/index'; -1 >Emitted(3, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(3, 34) Source(1, 36) + SourceIndex(0) ---- ->>>function getSecondsInDay() { -1 > -2 >^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^ -4 > ^^^^^^^-> -1 > - > -2 >export function -3 > getSecondsInDay -1 >Emitted(4, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(4, 10) Source(2, 17) + SourceIndex(0) -3 >Emitted(4, 25) Source(2, 32) + SourceIndex(0) ---- ->>> return c.multiply(10, 15); -1->^^^^ -2 > ^^^^^^^ -3 > ^ -4 > ^ -5 > ^^^^^^^^ -6 > ^ -7 > ^^ -8 > ^^ -9 > ^^ -10> ^ -11> ^ -1->() { - > -2 > return -3 > c -4 > . -5 > multiply -6 > ( -7 > 10 -8 > , -9 > 15 -10> ) -11> ; -1->Emitted(5, 5) Source(3, 5) + SourceIndex(0) -2 >Emitted(5, 12) Source(3, 12) + SourceIndex(0) -3 >Emitted(5, 13) Source(3, 13) + SourceIndex(0) -4 >Emitted(5, 14) Source(3, 14) + SourceIndex(0) -5 >Emitted(5, 22) Source(3, 22) + SourceIndex(0) -6 >Emitted(5, 23) Source(3, 23) + SourceIndex(0) -7 >Emitted(5, 25) Source(3, 25) + SourceIndex(0) -8 >Emitted(5, 27) Source(3, 27) + SourceIndex(0) -9 >Emitted(5, 29) Source(3, 29) + SourceIndex(0) -10>Emitted(5, 30) Source(3, 30) + SourceIndex(0) -11>Emitted(5, 31) Source(3, 31) + SourceIndex(0) ---- ->>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > -2 >} -1 >Emitted(6, 1) Source(4, 1) + SourceIndex(0) -2 >Emitted(6, 2) Source(4, 2) + SourceIndex(0) ---- ->>>exports.getSecondsInDay = getSecondsInDay; -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -3 > ^^-> -1-> -2 >export function getSecondsInDay() { - > return c.multiply(10, 15); - >} -1->Emitted(7, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(7, 43) Source(4, 2) + SourceIndex(0) ---- ->>>var mod = require("../core/anotherModule"); -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -1-> - > -2 >import * as mod from '../core/anotherModule'; -1->Emitted(8, 1) Source(5, 1) + SourceIndex(0) -2 >Emitted(8, 44) Source(5, 46) + SourceIndex(0) ---- ->>>exports.m = mod; -1 > -2 >^^^^^^^^ -3 > ^ -4 > ^^^ -5 > ^^^ -6 > ^ -7 > ^^^^^^^^^^^^^^^^-> -1 > - >export const -2 > -3 > m -4 > = -5 > mod -6 > ; -1 >Emitted(9, 1) Source(6, 14) + SourceIndex(0) -2 >Emitted(9, 9) Source(6, 14) + SourceIndex(0) -3 >Emitted(9, 10) Source(6, 15) + SourceIndex(0) -4 >Emitted(9, 13) Source(6, 18) + SourceIndex(0) -5 >Emitted(9, 16) Source(6, 21) + SourceIndex(0) -6 >Emitted(9, 17) Source(6, 22) + SourceIndex(0) ---- ->>>//# sourceMappingURL=index.js.map - -//// [/src/logic/tsconfig.tsbuildinfo] -{ - "program": { - "fileInfos": { - "../../lib/lib.d.ts": { - "version": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", - "signature": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };" - }, - "../core/index.ts": { - "version": "-13851440507-export declare const someString: string;\r\nexport declare function leftPad(s: string, n: number): string;\r\nexport declare function multiply(a: number, b: number): number;\r\n//# sourceMappingURL=index.d.ts.map", - "signature": "-13851440507-export declare const someString: string;\r\nexport declare function leftPad(s: string, n: number): string;\r\nexport declare function multiply(a: number, b: number): number;\r\n//# sourceMappingURL=index.d.ts.map" - }, - "../core/anothermodule.ts": { - "version": "7652028357-export declare const World = \"hello\";\r\n//# sourceMappingURL=anotherModule.d.ts.map", - "signature": "7652028357-export declare const World = \"hello\";\r\n//# sourceMappingURL=anotherModule.d.ts.map" - }, - "./index.ts": { - "version": "-5786964698-import * as c from '../core/index';\r\nexport function getSecondsInDay() {\r\n return c.multiply(10, 15);\r\n}\r\nimport * as mod from '../core/anotherModule';\r\nexport const m = mod;\r\n", - "signature": "-6548680073-export declare function getSecondsInDay(): number;\r\nimport * as mod from '../core/anotherModule';\r\nexport declare const m: typeof mod;\r\n" - } - }, - "options": { - "composite": true, - "declaration": true, - "sourceMap": true, - "forceConsistentCasingInFileNames": true, - "skipDefaultLibCheck": true, - "configFilePath": "./tsconfig.json" - }, - "referencedMap": { - "./index.ts": [ - "../core/anothermodule.d.ts", - "../core/index.d.ts" - ] - }, - "exportedModulesMap": { - "./index.ts": [ - "../core/anothermodule.d.ts" - ] - }, - "semanticDiagnosticsPerFile": [ - "../../lib/lib.d.ts", - "../core/anothermodule.ts", - "../core/index.ts", - "./index.ts" - ] - }, - "version": "FakeTSVersion" -} - -//// [/src/tests/index.d.ts] -import * as mod from '../core/anotherModule'; -export declare const m: typeof mod; - - -//// [/src/tests/index.js] -"use strict"; -exports.__esModule = true; -var c = require("../core/index"); -var logic = require("../logic/index"); -c.leftPad("", 10); -logic.getSecondsInDay(); -var mod = require("../core/anotherModule"); -exports.m = mod; - - -//// [/src/tests/tsconfig.tsbuildinfo] -{ - "program": { - "fileInfos": { - "../../lib/lib.d.ts": { - "version": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", - "signature": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };" - }, - "../core/index.ts": { - "version": "-13851440507-export declare const someString: string;\r\nexport declare function leftPad(s: string, n: number): string;\r\nexport declare function multiply(a: number, b: number): number;\r\n//# sourceMappingURL=index.d.ts.map", - "signature": "-13851440507-export declare const someString: string;\r\nexport declare function leftPad(s: string, n: number): string;\r\nexport declare function multiply(a: number, b: number): number;\r\n//# sourceMappingURL=index.d.ts.map" - }, - "../core/anothermodule.ts": { - "version": "7652028357-export declare const World = \"hello\";\r\n//# sourceMappingURL=anotherModule.d.ts.map", - "signature": "7652028357-export declare const World = \"hello\";\r\n//# sourceMappingURL=anotherModule.d.ts.map" - }, - "../logic/index.ts": { - "version": "-6548680073-export declare function getSecondsInDay(): number;\r\nimport * as mod from '../core/anotherModule';\r\nexport declare const m: typeof mod;\r\n", - "signature": "-6548680073-export declare function getSecondsInDay(): number;\r\nimport * as mod from '../core/anotherModule';\r\nexport declare const m: typeof mod;\r\n" - }, - "./index.ts": { - "version": "12336236525-import * as c from '../core/index';\r\nimport * as logic from '../logic/index';\r\n\r\nc.leftPad(\"\", 10);\r\nlogic.getSecondsInDay();\r\n\r\nimport * as mod from '../core/anotherModule';\r\nexport const m = mod;\r\n", - "signature": "-9209611-import * as mod from '../core/anotherModule';\r\nexport declare const m: typeof mod;\r\n" - } - }, - "options": { - "composite": true, - "declaration": true, - "forceConsistentCasingInFileNames": true, - "skipDefaultLibCheck": true, - "configFilePath": "./tsconfig.json" - }, - "referencedMap": { - "../logic/index.ts": [ - "../core/anothermodule.d.ts" - ], - "./index.ts": [ - "../core/anothermodule.d.ts", - "../core/index.d.ts", - "../logic/index.d.ts" - ] - }, - "exportedModulesMap": { - "../logic/index.ts": [ - "../core/anothermodule.d.ts" - ], - "./index.ts": [ - "../core/anothermodule.d.ts" - ] - }, - "semanticDiagnosticsPerFile": [ - "../../lib/lib.d.ts", - "../core/anothermodule.ts", - "../core/index.ts", - "../logic/index.ts", - "./index.ts" - ] - }, - "version": "FakeTSVersion" -} - diff --git a/tests/baselines/reference/tsbuild/sample1/initial-Build/sample.js b/tests/baselines/reference/tsbuild/sample1/initial-build/sample.js similarity index 92% rename from tests/baselines/reference/tsbuild/sample1/initial-Build/sample.js rename to tests/baselines/reference/tsbuild/sample1/initial-build/sample.js index 7a9f9a2ea95..00228056483 100644 --- a/tests/baselines/reference/tsbuild/sample1/initial-Build/sample.js +++ b/tests/baselines/reference/tsbuild/sample1/initial-build/sample.js @@ -1,3 +1,40 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/tests --verbose +12:01:00 AM - Projects in this build: + * src/core/tsconfig.json + * src/logic/tsconfig.json + * src/tests/tsconfig.json + +12:01:00 AM - Project 'src/core/tsconfig.json' is out of date because output file 'src/core/anotherModule.js' does not exist + +12:01:00 AM - Building project '/src/core/tsconfig.json'... + +12:01:00 AM - Project 'src/logic/tsconfig.json' is out of date because output file 'src/logic/index.js' does not exist + +12:01:00 AM - Building project '/src/logic/tsconfig.json'... + +12:01:00 AM - Project 'src/tests/tsconfig.json' is out of date because output file 'src/tests/index.js' does not exist + +12:01:00 AM - Building project '/src/tests/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/tests/tsconfig.json": 1, + "/src/core/tsconfig.json": 1, + "/src/logic/tsconfig.json": 1, + "/src/core/tsconfig.tsbuildinfo": 1, + "/src/core/anotherModule.ts": 1, + "/src/core/index.ts": 1, + "/src/core/some_decl.d.ts": 1, + "/src/logic/tsconfig.tsbuildinfo": 1, + "/src/logic/index.ts": 1, + "/src/core/index.d.ts": 1, + "/src/core/anotherModule.d.ts": 1, + "/src/tests/tsconfig.tsbuildinfo": 1, + "/src/tests/index.ts": 1, + "/src/logic/index.d.ts": 1 +} + //// [/src/core/anotherModule.d.ts] export declare const World = "hello"; //# sourceMappingURL=anotherModule.d.ts.map diff --git a/tests/baselines/reference/tsbuild/sample1/initial-Build/when-declaration-option-changes.js b/tests/baselines/reference/tsbuild/sample1/initial-build/when-declaration-option-changes.js similarity index 87% rename from tests/baselines/reference/tsbuild/sample1/initial-Build/when-declaration-option-changes.js rename to tests/baselines/reference/tsbuild/sample1/initial-build/when-declaration-option-changes.js index 61e87a815aa..6fcba548d3b 100644 --- a/tests/baselines/reference/tsbuild/sample1/initial-Build/when-declaration-option-changes.js +++ b/tests/baselines/reference/tsbuild/sample1/initial-build/when-declaration-option-changes.js @@ -1,3 +1,15 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/core --verbose +12:01:00 AM - Projects in this build: + * src/core/tsconfig.json + +12:01:00 AM - Project 'src/core/tsconfig.json' is out of date because output file 'src/core/anotherModule.js' does not exist + +12:01:00 AM - Building project '/src/core/tsconfig.json'... + +exitCode:: 0 + + //// [/src/core/anotherModule.js] "use strict"; exports.__esModule = true; diff --git a/tests/baselines/reference/tsbuild/sample1/initial-Build/when-esModuleInterop-option-changes.js b/tests/baselines/reference/tsbuild/sample1/initial-build/when-esModuleInterop-option-changes.js similarity index 92% rename from tests/baselines/reference/tsbuild/sample1/initial-Build/when-esModuleInterop-option-changes.js rename to tests/baselines/reference/tsbuild/sample1/initial-build/when-esModuleInterop-option-changes.js index e24ade14d9d..0f1ea65c5e4 100644 --- a/tests/baselines/reference/tsbuild/sample1/initial-Build/when-esModuleInterop-option-changes.js +++ b/tests/baselines/reference/tsbuild/sample1/initial-build/when-esModuleInterop-option-changes.js @@ -1,3 +1,25 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/tests --verbose +12:01:00 AM - Projects in this build: + * src/core/tsconfig.json + * src/logic/tsconfig.json + * src/tests/tsconfig.json + +12:01:00 AM - Project 'src/core/tsconfig.json' is out of date because output file 'src/core/anotherModule.js' does not exist + +12:01:00 AM - Building project '/src/core/tsconfig.json'... + +12:01:00 AM - Project 'src/logic/tsconfig.json' is out of date because output file 'src/logic/index.js' does not exist + +12:01:00 AM - Building project '/src/logic/tsconfig.json'... + +12:01:00 AM - Project 'src/tests/tsconfig.json' is out of date because output file 'src/tests/index.js' does not exist + +12:01:00 AM - Building project '/src/tests/tsconfig.json'... + +exitCode:: 0 + + //// [/src/core/anotherModule.d.ts] export declare const World = "hello"; //# sourceMappingURL=anotherModule.d.ts.map diff --git a/tests/baselines/reference/tsbuild/sample1/initial-Build/when-logic-specifies-tsBuildInfoFile.js b/tests/baselines/reference/tsbuild/sample1/initial-build/when-logic-specifies-tsBuildInfoFile.js similarity index 92% rename from tests/baselines/reference/tsbuild/sample1/initial-Build/when-logic-specifies-tsBuildInfoFile.js rename to tests/baselines/reference/tsbuild/sample1/initial-build/when-logic-specifies-tsBuildInfoFile.js index b7623e1af56..fe60d8093d4 100644 --- a/tests/baselines/reference/tsbuild/sample1/initial-Build/when-logic-specifies-tsBuildInfoFile.js +++ b/tests/baselines/reference/tsbuild/sample1/initial-build/when-logic-specifies-tsBuildInfoFile.js @@ -1,3 +1,40 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/tests --verbose +12:00:00 AM - Projects in this build: + * src/core/tsconfig.json + * src/logic/tsconfig.json + * src/tests/tsconfig.json + +12:00:00 AM - Project 'src/core/tsconfig.json' is out of date because output file 'src/core/anotherModule.js' does not exist + +12:00:00 AM - Building project '/src/core/tsconfig.json'... + +12:00:00 AM - Project 'src/logic/tsconfig.json' is out of date because output file 'src/logic/index.js' does not exist + +12:00:00 AM - Building project '/src/logic/tsconfig.json'... + +12:00:00 AM - Project 'src/tests/tsconfig.json' is out of date because output file 'src/tests/index.js' does not exist + +12:00:00 AM - Building project '/src/tests/tsconfig.json'... + +exitCode:: 0 +readFiles:: { + "/src/tests/tsconfig.json": 1, + "/src/core/tsconfig.json": 1, + "/src/logic/tsconfig.json": 1, + "/src/core/tsconfig.tsbuildinfo": 1, + "/src/core/anotherModule.ts": 1, + "/src/core/index.ts": 1, + "/src/core/some_decl.d.ts": 1, + "/src/logic/ownFile.tsbuildinfo": 1, + "/src/logic/index.ts": 1, + "/src/core/index.d.ts": 1, + "/src/core/anotherModule.d.ts": 1, + "/src/tests/tsconfig.tsbuildinfo": 1, + "/src/tests/index.ts": 1, + "/src/logic/index.d.ts": 1 +} + //// [/src/core/anotherModule.d.ts] export declare const World = "hello"; //# sourceMappingURL=anotherModule.d.ts.map diff --git a/tests/baselines/reference/tsbuild/sample1/initial-Build/when-module-option-changes.js b/tests/baselines/reference/tsbuild/sample1/initial-build/when-module-option-changes.js similarity index 87% rename from tests/baselines/reference/tsbuild/sample1/initial-Build/when-module-option-changes.js rename to tests/baselines/reference/tsbuild/sample1/initial-build/when-module-option-changes.js index ad19329a2e0..c890f0d5766 100644 --- a/tests/baselines/reference/tsbuild/sample1/initial-Build/when-module-option-changes.js +++ b/tests/baselines/reference/tsbuild/sample1/initial-build/when-module-option-changes.js @@ -1,3 +1,15 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/core --verbose +12:01:00 AM - Projects in this build: + * src/core/tsconfig.json + +12:01:00 AM - Project 'src/core/tsconfig.json' is out of date because output file 'src/core/anotherModule.js' does not exist + +12:01:00 AM - Building project '/src/core/tsconfig.json'... + +exitCode:: 0 + + //// [/src/core/anotherModule.js] "use strict"; exports.__esModule = true; diff --git a/tests/baselines/reference/tsbuild/sample1/initial-Build/when-target-option-changes.js b/tests/baselines/reference/tsbuild/sample1/initial-build/when-target-option-changes.js similarity index 85% rename from tests/baselines/reference/tsbuild/sample1/initial-Build/when-target-option-changes.js rename to tests/baselines/reference/tsbuild/sample1/initial-build/when-target-option-changes.js index c8fc2b1fbde..c615f77eb86 100644 --- a/tests/baselines/reference/tsbuild/sample1/initial-Build/when-target-option-changes.js +++ b/tests/baselines/reference/tsbuild/sample1/initial-build/when-target-option-changes.js @@ -1,3 +1,23 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/core --verbose +12:01:00 AM - Projects in this build: + * src/core/tsconfig.json + +12:01:00 AM - Project 'src/core/tsconfig.json' is out of date because output file 'src/core/anotherModule.js' does not exist + +12:01:00 AM - Building project '/src/core/tsconfig.json'... + +TSFILE: /src/core/anotherModule.js +TSFILE: /src/core/index.js +TSFILE: /src/core/tsconfig.tsbuildinfo +/lib/lib.esnext.d.ts +/lib/lib.esnext.full.d.ts +/src/core/anotherModule.ts +/src/core/index.ts +/src/core/some_decl.d.ts +exitCode:: 0 + + //// [/lib/lib.d.ts] /// /// diff --git a/tests/baselines/reference/tsc/declarationEmit/initial-build/when-pkg-references-sibling-package-through-indirect-symlink.js b/tests/baselines/reference/tsc/declarationEmit/initial-build/when-pkg-references-sibling-package-through-indirect-symlink.js new file mode 100644 index 00000000000..42cb6cf78c8 --- /dev/null +++ b/tests/baselines/reference/tsc/declarationEmit/initial-build/when-pkg-references-sibling-package-through-indirect-symlink.js @@ -0,0 +1,33 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc -p src/pkg3 --listFiles +src/pkg3/src/keys.ts(2,14): error TS2742: The inferred type of 'ADMIN' cannot be named without a reference to '@raymondfeng/pkg2/node_modules/@raymondfeng/pkg1'. This is likely not portable. A type annotation is necessary. +/lib/lib.d.ts +/src/pkg3/node_modules/@raymondfeng/pkg2/node_modules/@raymondfeng/pkg1/dist/types.d.ts +/src/pkg3/node_modules/@raymondfeng/pkg2/node_modules/@raymondfeng/pkg1/dist/index.d.ts +/src/pkg3/node_modules/@raymondfeng/pkg2/dist/types.d.ts +/src/pkg3/node_modules/@raymondfeng/pkg2/dist/index.d.ts +/src/pkg3/src/keys.ts +/src/pkg3/src/index.ts +exitCode:: 1 + + +//// [/src/pkg3/dist/index.d.ts] +export * from './keys'; + + +//// [/src/pkg3/dist/index.js] +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +__export(require("./keys")); + + +//// [/src/pkg3/dist/keys.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var pkg2_1 = require("@raymondfeng/pkg2"); +exports.ADMIN = pkg2_1.MetadataAccessor.create('1'); + + diff --git a/tests/baselines/reference/tsc/declarationEmit/initial-build/when-same-version-is-referenced-through-source-and-another-symlinked-package.js b/tests/baselines/reference/tsc/declarationEmit/initial-build/when-same-version-is-referenced-through-source-and-another-symlinked-package.js new file mode 100644 index 00000000000..910b9d1db3a --- /dev/null +++ b/tests/baselines/reference/tsc/declarationEmit/initial-build/when-same-version-is-referenced-through-source-and-another-symlinked-package.js @@ -0,0 +1,37 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc -p src/plugin-one --listFiles +/lib/lib.d.ts +/src/plugin-one/node_modules/typescript-fsa/index.d.ts +/src/plugin-one/action.ts +/src/plugin-one/node_modules/plugin-two/node_modules/typescript-fsa/index.d.ts -> /src/plugin-one/node_modules/typescript-fsa/index.d.ts +/src/plugin-one/node_modules/plugin-two/index.d.ts +/src/plugin-one/index.ts +exitCode:: 0 + + +//// [/src/plugin-one/action.d.ts] +export declare const actions: { + featureOne: import("typescript-fsa").ActionCreator<{ + route: string; + }>; +}; + + +//// [/src/plugin-one/action.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var typescript_fsa_1 = require("typescript-fsa"); // Include version of shared lib +var action = typescript_fsa_1.actionCreatorFactory("somekey"); +var featureOne = action("feature-one"); +exports.actions = { featureOne: featureOne }; + + +//// [/src/plugin-one/index.d.ts] +export {}; + + +//// [/src/plugin-one/index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); + + diff --git a/tests/baselines/reference/tsxAttributeResolution1.errors.txt b/tests/baselines/reference/tsxAttributeResolution1.errors.txt index 9fc3e8f94da..46ccb39e704 100644 --- a/tests/baselines/reference/tsxAttributeResolution1.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution1.errors.txt @@ -1,10 +1,10 @@ tests/cases/conformance/jsx/file.tsx(23,8): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/jsx/file.tsx(24,2): error TS2322: Type '{ y: number; }' is not assignable to type 'Attribs1'. +tests/cases/conformance/jsx/file.tsx(24,8): error TS2322: Type '{ y: number; }' is not assignable to type 'Attribs1'. Property 'y' does not exist on type 'Attribs1'. -tests/cases/conformance/jsx/file.tsx(25,2): error TS2322: Type '{ y: string; }' is not assignable to type 'Attribs1'. +tests/cases/conformance/jsx/file.tsx(25,8): error TS2322: Type '{ y: string; }' is not assignable to type 'Attribs1'. Property 'y' does not exist on type 'Attribs1'. tests/cases/conformance/jsx/file.tsx(26,8): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/jsx/file.tsx(27,2): error TS2322: Type '{ var: string; }' is not assignable to type 'Attribs1'. +tests/cases/conformance/jsx/file.tsx(27,8): error TS2322: Type '{ var: string; }' is not assignable to type 'Attribs1'. Property 'var' does not exist on type 'Attribs1'. tests/cases/conformance/jsx/file.tsx(29,2): error TS2741: Property 'reqd' is missing in type '{}' but required in type '{ reqd: string; }'. tests/cases/conformance/jsx/file.tsx(30,8): error TS2322: Type 'number' is not assignable to type 'string'. @@ -38,11 +38,11 @@ tests/cases/conformance/jsx/file.tsx(30,8): error TS2322: Type 'number' is not a !!! error TS2322: Type 'string' is not assignable to type 'number'. !!! related TS6500 tests/cases/conformance/jsx/file.tsx:10:2: The expected type comes from property 'x' which is declared here on type 'Attribs1' ; // Error, no property "y" - ~~~~~ + ~ !!! error TS2322: Type '{ y: number; }' is not assignable to type 'Attribs1'. !!! error TS2322: Property 'y' does not exist on type 'Attribs1'. ; // Error, no property "y" - ~~~~~ + ~ !!! error TS2322: Type '{ y: string; }' is not assignable to type 'Attribs1'. !!! error TS2322: Property 'y' does not exist on type 'Attribs1'. ; // Error, "32" is not number @@ -50,7 +50,7 @@ tests/cases/conformance/jsx/file.tsx(30,8): error TS2322: Type 'number' is not a !!! error TS2322: Type 'string' is not assignable to type 'number'. !!! related TS6500 tests/cases/conformance/jsx/file.tsx:10:2: The expected type comes from property 'x' which is declared here on type 'Attribs1' ; // Error, no 'var' property - ~~~~~ + ~~~ !!! error TS2322: Type '{ var: string; }' is not assignable to type 'Attribs1'. !!! error TS2322: Property 'var' does not exist on type 'Attribs1'. diff --git a/tests/baselines/reference/tsxAttributeResolution11.errors.txt b/tests/baselines/reference/tsxAttributeResolution11.errors.txt index 6c6a23a9b70..d490faad314 100644 --- a/tests/baselines/reference/tsxAttributeResolution11.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution11.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsx/file.tsx(11,10): error TS2322: Type '{ bar: string; }' is not assignable to type 'IntrinsicAttributes & { ref?: string; }'. +tests/cases/conformance/jsx/file.tsx(11,22): error TS2322: Type '{ bar: string; }' is not assignable to type 'IntrinsicAttributes & { ref?: string; }'. Property 'bar' does not exist on type 'IntrinsicAttributes & { ref?: string; }'. @@ -27,7 +27,7 @@ tests/cases/conformance/jsx/file.tsx(11,10): error TS2322: Type '{ bar: string; // Should be an OK var x = ; - ~~~~~~~~~~~ + ~~~ !!! error TS2322: Type '{ bar: string; }' is not assignable to type 'IntrinsicAttributes & { ref?: string; }'. !!! error TS2322: Property 'bar' does not exist on type 'IntrinsicAttributes & { ref?: string; }'. diff --git a/tests/baselines/reference/tsxAttributeResolution15.errors.txt b/tests/baselines/reference/tsxAttributeResolution15.errors.txt index ca86178b578..7ec97ba4675 100644 --- a/tests/baselines/reference/tsxAttributeResolution15.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution15.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsx/file.tsx(11,10): error TS2322: Type '{ prop1: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & { children?: ReactNode; }'. +tests/cases/conformance/jsx/file.tsx(11,21): error TS2322: Type '{ prop1: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & { children?: ReactNode; }'. Property 'prop1' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & { children?: ReactNode; }'. tests/cases/conformance/jsx/file.tsx(14,44): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature. @@ -15,7 +15,7 @@ tests/cases/conformance/jsx/file.tsx(14,44): error TS7017: Element implicitly ha // Error let a = - ~~~~~~~~~~ + ~~~~~ !!! error TS2322: Type '{ prop1: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & { children?: ReactNode; }'. !!! error TS2322: Property 'prop1' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & { children?: ReactNode; }'. diff --git a/tests/baselines/reference/tsxElementResolution11.errors.txt b/tests/baselines/reference/tsxElementResolution11.errors.txt index d08a6ed2721..cc032610e2b 100644 --- a/tests/baselines/reference/tsxElementResolution11.errors.txt +++ b/tests/baselines/reference/tsxElementResolution11.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsx/file.tsx(17,2): error TS2322: Type '{ x: number; }' is not assignable to type '{ q?: number; }'. +tests/cases/conformance/jsx/file.tsx(17,7): error TS2322: Type '{ x: number; }' is not assignable to type '{ q?: number; }'. Property 'x' does not exist on type '{ q?: number; }'. @@ -20,7 +20,7 @@ tests/cases/conformance/jsx/file.tsx(17,2): error TS2322: Type '{ x: number; }' } var Obj2: Obj2type; ; // Error - ~~~~ + ~ !!! error TS2322: Type '{ x: number; }' is not assignable to type '{ q?: number; }'. !!! error TS2322: Property 'x' does not exist on type '{ q?: number; }'. diff --git a/tests/baselines/reference/tsxElementResolution3.errors.txt b/tests/baselines/reference/tsxElementResolution3.errors.txt index f220dbd8a5b..8f8679b3857 100644 --- a/tests/baselines/reference/tsxElementResolution3.errors.txt +++ b/tests/baselines/reference/tsxElementResolution3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsx/file.tsx(12,2): error TS2322: Type '{ w: string; }' is not assignable to type '{ n: string; }'. +tests/cases/conformance/jsx/file.tsx(12,7): error TS2322: Type '{ w: string; }' is not assignable to type '{ n: string; }'. Property 'w' does not exist on type '{ n: string; }'. @@ -15,6 +15,6 @@ tests/cases/conformance/jsx/file.tsx(12,2): error TS2322: Type '{ w: string; }' // Error ; - ~~~~ + ~ !!! error TS2322: Type '{ w: string; }' is not assignable to type '{ n: string; }'. !!! error TS2322: Property 'w' does not exist on type '{ n: string; }'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution4.errors.txt b/tests/baselines/reference/tsxElementResolution4.errors.txt index f76925030f2..235adbb199a 100644 --- a/tests/baselines/reference/tsxElementResolution4.errors.txt +++ b/tests/baselines/reference/tsxElementResolution4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsx/file.tsx(16,2): error TS2322: Type '{ q: string; }' is not assignable to type '{ m: string; }'. +tests/cases/conformance/jsx/file.tsx(16,7): error TS2322: Type '{ q: string; }' is not assignable to type '{ m: string; }'. Property 'q' does not exist on type '{ m: string; }'. @@ -19,7 +19,7 @@ tests/cases/conformance/jsx/file.tsx(16,2): error TS2322: Type '{ q: string; }' // Error ; - ~~~~ + ~ !!! error TS2322: Type '{ q: string; }' is not assignable to type '{ m: string; }'. !!! error TS2322: Property 'q' does not exist on type '{ m: string; }'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxLibraryManagedAttributes.errors.txt b/tests/baselines/reference/tsxLibraryManagedAttributes.errors.txt index b34ee77d1fb..4b4448e42f6 100644 --- a/tests/baselines/reference/tsxLibraryManagedAttributes.errors.txt +++ b/tests/baselines/reference/tsxLibraryManagedAttributes.errors.txt @@ -1,22 +1,22 @@ tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(55,12): error TS2322: Type '{ foo: number; }' is not assignable to type 'Defaultize; bar: PropTypeChecker; baz: PropTypeChecker; }>, { foo: number; }>'. Type '{ foo: number; }' is missing the following properties from type '{ bar: string | number | ReactComponent<{}, {}> | null | undefined; baz: string; }': bar, baz -tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(57,12): error TS2322: Type '{ bar: string; baz: string; bat: string; }' is not assignable to type 'Defaultize; bar: PropTypeChecker; baz: PropTypeChecker; }>, { foo: number; }>'. +tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(57,41): error TS2322: Type '{ bar: string; baz: string; bat: string; }' is not assignable to type 'Defaultize; bar: PropTypeChecker; baz: PropTypeChecker; }>, { foo: number; }>'. Property 'bat' does not exist on type 'Defaultize; bar: PropTypeChecker; baz: PropTypeChecker; }>, { foo: number; }>'. tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(59,42): error TS2322: Type 'null' is not assignable to type 'string'. tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(69,26): error TS2322: Type 'string' is not assignable to type 'number | null | undefined'. tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(71,35): error TS2322: Type 'null' is not assignable to type 'ReactNode'. -tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(80,12): error TS2322: Type '{ foo: number; bar: string; }' is not assignable to type 'Defaultize<{}, { foo: number; }>'. +tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(80,38): error TS2322: Type '{ foo: number; bar: string; }' is not assignable to type 'Defaultize<{}, { foo: number; }>'. Property 'bar' does not exist on type 'Defaultize<{}, { foo: number; }>'. tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(81,29): error TS2322: Type 'string' is not assignable to type 'number | undefined'. tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(98,12): error TS2322: Type '{ foo: string; }' is not assignable to type 'Defaultize; bar: PropTypeChecker; baz: PropTypeChecker; }>, { foo: string; }>'. Type '{ foo: string; }' is missing the following properties from type '{ bar: string | number | ReactComponent<{}, {}> | null | undefined; baz: number; }': bar, baz -tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(100,12): error TS2322: Type '{ bar: string; baz: number; bat: string; }' is not assignable to type 'Defaultize; bar: PropTypeChecker; baz: PropTypeChecker; }>, { foo: string; }>'. +tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(100,56): error TS2322: Type '{ bar: string; baz: number; bat: string; }' is not assignable to type 'Defaultize; bar: PropTypeChecker; baz: PropTypeChecker; }>, { foo: string; }>'. Property 'bat' does not exist on type 'Defaultize; bar: PropTypeChecker; baz: PropTypeChecker; }>, { foo: string; }>'. tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(102,57): error TS2322: Type 'null' is not assignable to type 'number'. tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(111,46): error TS2322: Type 'number' is not assignable to type 'string'. tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(112,46): error TS2322: Type 'null' is not assignable to type 'string'. tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(113,57): error TS2322: Type 'null' is not assignable to type 'ReactNode'. -tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(122,12): error TS2322: Type '{ foo: string; bar: string; }' is not assignable to type 'Defaultize'. +tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(122,58): error TS2322: Type '{ foo: string; bar: string; }' is not assignable to type 'Defaultize'. Property 'bar' does not exist on type 'Defaultize'. tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(123,49): error TS2322: Type 'number' is not assignable to type 'string | undefined'. @@ -82,7 +82,7 @@ tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(123,49): error TS232 !!! error TS2322: Type '{ foo: number; }' is missing the following properties from type '{ bar: string | number | ReactComponent<{}, {}> | null | undefined; baz: string; }': bar, baz const c = ; const d = ; // Error, baz not a valid prop - ~~~~~~~~~ + ~~~ !!! error TS2322: Type '{ bar: string; baz: string; bat: string; }' is not assignable to type 'Defaultize; bar: PropTypeChecker; baz: PropTypeChecker; }>, { foo: number; }>'. !!! error TS2322: Property 'bat' does not exist on type 'Defaultize; bar: PropTypeChecker; baz: PropTypeChecker; }>, { foo: number; }>'. const e = ; // bar is nullable/undefinable since it's not marked `isRequired` @@ -116,7 +116,7 @@ tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(123,49): error TS232 const k = ; const l = ; // error, no prop named bar - ~~~~~~~~~~~~~~~~ + ~~~ !!! error TS2322: Type '{ foo: number; bar: string; }' is not assignable to type 'Defaultize<{}, { foo: number; }>'. !!! error TS2322: Property 'bar' does not exist on type 'Defaultize<{}, { foo: number; }>'. const m = ; // error, wrong type @@ -145,7 +145,7 @@ tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(123,49): error TS232 !!! error TS2322: Type '{ foo: string; }' is missing the following properties from type '{ bar: string | number | ReactComponent<{}, {}> | null | undefined; baz: number; }': bar, baz const p = ; const q = ; // Error, baz not a valid prop - ~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~ !!! error TS2322: Type '{ bar: string; baz: number; bat: string; }' is not assignable to type 'Defaultize; bar: PropTypeChecker; baz: PropTypeChecker; }>, { foo: string; }>'. !!! error TS2322: Property 'bat' does not exist on type 'Defaultize; bar: PropTypeChecker; baz: PropTypeChecker; }>, { foo: string; }>'. const r = ; // bar is nullable/undefinable since it's not marked `isRequired` @@ -181,7 +181,7 @@ tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(123,49): error TS232 const x = ; const y = ; // error, no prop named bar - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~ !!! error TS2322: Type '{ foo: string; bar: string; }' is not assignable to type 'Defaultize'. !!! error TS2322: Property 'bar' does not exist on type 'Defaultize'. const z = ; // error, wrong type diff --git a/tests/baselines/reference/tsxReactPropsInferenceSucceedsOnIntersections.types b/tests/baselines/reference/tsxReactPropsInferenceSucceedsOnIntersections.types index 16b5cd13636..3fa0b722aa4 100644 --- a/tests/baselines/reference/tsxReactPropsInferenceSucceedsOnIntersections.types +++ b/tests/baselines/reference/tsxReactPropsInferenceSucceedsOnIntersections.types @@ -25,7 +25,7 @@ interface CustomButtonProps extends ButtonProps { } const CustomButton: React.SFC = props =>