diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 843b5b2f94d66..071ad5912a26e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -81,9 +81,9 @@ import { classOrConstructorParameterIsDecorated, ClassStaticBlockDeclaration, clear, + compareComparableValues, compareDiagnostics, comparePaths, - compareValues, Comparison, CompilerOptions, ComputedPropertyName, @@ -424,6 +424,7 @@ import { Identifier, identifierToKeywordKind, IdentifierTypePredicate, + identity, idText, IfStatement, ImportAttribute, @@ -1492,6 +1493,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { var scanner: Scanner | undefined; + var fileIndexMap = new Map(host.getSourceFiles().map((file, i) => [file, i])); + var Symbol = objectAllocator.getSymbolConstructor(); var Type = objectAllocator.getTypeConstructor(); var Signature = objectAllocator.getSignatureConstructor(); @@ -5441,7 +5444,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function createTypeofType() { - return getUnionType(arrayFrom(typeofNEFacts.keys(), getStringLiteralType)); + return getUnionType(map([...typeofNEFacts.keys()].sort(), getStringLiteralType)); } function createTypeParameter(symbol?: Symbol) { @@ -17400,11 +17403,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function containsType(types: readonly Type[], type: Type): boolean { - return binarySearch(types, type, getTypeId, compareValues) >= 0; + return binarySearch(types, type, identity, compareTypes) >= 0; } function insertType(types: Type[], type: Type): boolean { - const index = binarySearch(types, type, getTypeId, compareValues); + const index = binarySearch(types, type, identity, compareTypes); if (index < 0) { types.splice(~index, 0, type); return true; @@ -17425,8 +17428,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (!(getObjectFlags(type) & ObjectFlags.ContainsWideningType)) includes |= TypeFlags.IncludesNonWideningType; } else { - const len = typeSet.length; - const index = len && type.id > typeSet[len - 1].id ? ~len : binarySearch(typeSet, type, getTypeId, compareValues); + const index = binarySearch(typeSet, type, identity, compareTypes); if (index < 0) { typeSet.splice(~index, 0, type); } @@ -52817,6 +52819,384 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { Debug.assert(specifier && nodeIsSynthesized(specifier) && specifier.text === "tslib", `Expected sourceFile.imports[0] to be the synthesized tslib import`); return specifier; } + + function compareSymbols(s1: Symbol | undefined, s2: Symbol | undefined): number { + if (s1 === s2) return 0; + if (s1 === undefined) return 1; + if (s2 === undefined) return -1; + if (length(s1.declarations) !== 0 && length(s2.declarations) !== 0) { + const r = compareNodes(s1.declarations![0], s2.declarations![0]); + if (r !== 0) return r; + } + else if (length(s1.declarations) !== 0) { + return -1; + } + else if (length(s2.declarations) !== 0) { + return 1; + } + const r = compareComparableValues(s1.escapedName as string, s2.escapedName as string); + if (r !== 0) return r; + return getSymbolId(s1) - getSymbolId(s2); + } + + function compareNodes(n1: Node | undefined, n2: Node | undefined): number { + if (n1 === n2) return 0; + if (n1 === undefined) return 1; + if (n2 === undefined) return -1; + const f1 = fileIndexMap.get(getSourceFileOfNode(n1))!; + const f2 = fileIndexMap.get(getSourceFileOfNode(n2))!; + if (f1 !== f2) { + // Order by index of file in the containing program + return f1 - f2; + } + // In the same file, order by source position + return n1.pos - n2.pos; + } + + function compareTypes(t1: Type | undefined, t2: Type | undefined): number { + if (t1 === t2) return 0; + if (t1 === undefined) return 1; + if (t2 === undefined) return -1; + + // First sort in order of increasing type flags values. + let c = getSortOrderFlags(t1) - getSortOrderFlags(t2); + if (c !== 0) return c; + + // Order named types by name and, in the case of aliased types, by alias type arguments. + c = compareTypeNames(t1, t2); + if (c !== 0) return c; + + // We have unnamed types or types with identical names. Now sort by data specific to the type. + if (t1.flags & (TypeFlags.Any | TypeFlags.Unknown | TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.BigInt | TypeFlags.ESSymbol | TypeFlags.Void | TypeFlags.Undefined | TypeFlags.Null | TypeFlags.Never | TypeFlags.NonPrimitive)) { + // Only distinguished by type IDs, handled below. + } + else if (t1.flags & TypeFlags.Object) { + // Order unnamed or identically named object types by symbol. + const c = compareSymbols(t1.symbol, t2.symbol); + if (c !== 0) return c; + + // When object types have the same or no symbol, order by kind. We order type references before other kinds. + if (getObjectFlags(t1) & ObjectFlags.Reference && getObjectFlags(t2) & ObjectFlags.Reference) { + const r1 = t1 as TypeReference; + const r2 = t2 as TypeReference; + if (getObjectFlags(r1.target) & ObjectFlags.Tuple && getObjectFlags(r2.target) & ObjectFlags.Tuple) { + // Tuple types have no associated symbol, instead we order by tuple element information. + const c = compareTupleTypes(r1.target as TupleType, r2.target as TupleType); + if (c !== 0) { + return c; + } + } + // Here we know we have references to instantiations of the same type because we have matching targets. + if (r1.node === undefined && r2.node === undefined) { + // Non-deferred type references with the same target are sorted by their type argument lists. + const c = compareTypeLists((t1 as TypeReference).resolvedTypeArguments, (t2 as TypeReference).resolvedTypeArguments); + if (c !== 0) { + return c; + } + } + else { + // Deferred type references with the same target are ordered by the source location of the reference. + let c = compareNodes(r1.node, r2.node); + if (c !== 0) { + return c; + } + // Instantiations of the same deferred type reference are ordered by their associated type mappers + // (which reflect the mapping of in-scope type parameters to type arguments). + c = compareTypeMappers((t1 as AnonymousType).mapper, (t2 as AnonymousType).mapper); + if (c !== 0) { + return c; + } + } + } + else if (getObjectFlags(t1) & ObjectFlags.Reference) { + return -1; + } + else if (getObjectFlags(t2) & ObjectFlags.Reference) { + return 1; + } + else { + // Order unnamed non-reference object types by kind associated type mappers. Reverse mapped types have + // neither symbols nor mappers so they're ultimately ordered by unstable type IDs, but given their rarity + // this should be fine. + let c = getObjectFlags(t1) & ObjectFlags.ObjectTypeKindMask - getObjectFlags(t2) & ObjectFlags.ObjectTypeKindMask; + if (c !== 0) { + return c; + } + c = compareTypeMappers((t1 as AnonymousType).mapper, (t2 as AnonymousType).mapper); + if (c !== 0) { + return c; + } + } + } + else if (t1.flags & TypeFlags.Union) { + // Unions are ordered by origin and then constituent type lists. + const o1 = (t1 as UnionType).origin; + const o2 = (t2 as UnionType).origin; + if (o1 === undefined && o2 === undefined) { + const c = compareTypeLists((t1 as UnionType).types, (t2 as UnionType).types); + if (c !== 0) { + return c; + } + } + else if (o1 === undefined) { + return 1; + } + else if (o2 === undefined) { + return -1; + } + else { + const c = compareTypes(o1, o2); + if (c !== 0) { + return c; + } + } + } + else if (t1.flags & TypeFlags.Intersection) { + // Intersections are ordered by their constituent type lists. + const c = compareTypeLists((t1 as IntersectionType).types, (t2 as IntersectionType).types); + if (c !== 0) { + return c; + } + } + else if (t1.flags & (TypeFlags.Enum | TypeFlags.EnumLiteral | TypeFlags.UniqueESSymbol)) { + // Enum members are ordered by their symbol (and thus their declaration order). + const c = compareSymbols(t1.symbol, t2.symbol); + if (c !== 0) { + return c; + } + } + else if (t1.flags & TypeFlags.StringLiteral) { + // String literal types are ordered by their values. + const c = compareComparableValues((t1 as LiteralType).value as string, (t2 as LiteralType).value as string); + if (c !== 0) { + return c; + } + } + else if (t1.flags & TypeFlags.NumberLiteral) { + // Numeric literal types are ordered by their values. + const c = compareComparableValues((t1 as LiteralType).value as number, (t2 as LiteralType).value as number); + if (c !== 0) { + return c; + } + } + else if (t1.flags & TypeFlags.BooleanLiteral) { + const b1 = (t1 as IntrinsicType).intrinsicName === "true"; + const b2 = (t2 as IntrinsicType).intrinsicName === "true"; + if (b1 !== b2) { + if (b1) { + return 1; + } + return -1; + } + } + else if (t1.flags & TypeFlags.TypeParameter) { + const c = compareSymbols(t1.symbol, t2.symbol); + if (c !== 0) { + return c; + } + } + else if (t1.flags & TypeFlags.Index) { + let c = compareTypes((t1 as IndexType).type, (t2 as IndexType).type); + if (c !== 0) { + return c; + } + c = (t1 as IndexType).flags - (t2 as IndexType).flags; + if (c !== 0) { + return c; + } + } + else if (t1.flags & TypeFlags.IndexedAccess) { + let c = compareTypes((t1 as IndexedAccessType).objectType, (t2 as IndexedAccessType).objectType); + if (c !== 0) { + return c; + } + c = compareTypes((t1 as IndexedAccessType).indexType, (t2 as IndexedAccessType).indexType); + if (c !== 0) { + return c; + } + } + else if (t1.flags & TypeFlags.Conditional) { + let c = compareNodes((t1 as ConditionalType).root.node, (t2 as ConditionalType).root.node); + if (c !== 0) { + return c; + } + c = compareTypeMappers((t1 as ConditionalType).mapper, (t2 as ConditionalType).mapper); + if (c !== 0) { + return c; + } + } + else if (t1.flags & TypeFlags.Substitution) { + let c = compareTypes((t1 as SubstitutionType).baseType, (t2 as SubstitutionType).baseType); + if (c !== 0) { + return c; + } + c = compareTypes((t1 as SubstitutionType).constraint, (t2 as SubstitutionType).constraint); + if (c !== 0) { + return c; + } + } + else if (t1.flags & TypeFlags.TemplateLiteral) { + let c = slicesCompareString((t1 as TemplateLiteralType).texts, (t2 as TemplateLiteralType).texts); + if (c !== 0) { + return c; + } + c = compareTypeLists((t1 as TemplateLiteralType).types, (t2 as TemplateLiteralType).types); + if (c !== 0) { + return c; + } + } + else if (t1.flags & TypeFlags.StringMapping) { + const c = compareTypes((t1 as StringMappingType).type, (t2 as StringMappingType).type); + if (c !== 0) { + return c; + } + } + + // Fall back to type IDs. This results in type creation order for built-in types. + return t1.id - t2.id; + + function slicesCompareString(s1: readonly string[], s2: readonly string[]): number { + for (let i = 0; i < s1.length; i++) { + if (i > s2.length) { + return 1; + } + const v1 = s1[i]; + const v2 = s2[i]; + const c = compareComparableValues(v1, v2); + if (c !== 0) return c; + } + if (s1.length < s2.length) { + return -1; + } + return 0; + } + } + + function getSortOrderFlags(t: Type): number { + // Return TypeFlagsEnum for all enum-like unit types (they'll be sorted by their symbols) + if (t.flags & (TypeFlags.EnumLiteral | TypeFlags.Enum) && !(t.flags & TypeFlags.Union)) { + return TypeFlags.Enum; + } + return t.flags; + } + + function compareTypeNames(t1: Type, t2: Type): number { + const s1 = getTypeNameSymbol(t1); + const s2 = getTypeNameSymbol(t2); + if (s1 === s2) { + if (t1.aliasTypeArguments !== undefined) { + return compareTypeLists(t1.aliasTypeArguments, t2.aliasTypeArguments); + } + return 0; + } + if (s1 === undefined) { + return 1; + } + if (s2 === undefined) { + return -1; + } + return compareComparableValues(s1.escapedName as string, s2.escapedName as string); + } + + function getTypeNameSymbol(t: Type): Symbol | undefined { + if (t.aliasSymbol !== undefined) { + return t.aliasSymbol; + } + if (t.flags & (TypeFlags.TypeParameter | TypeFlags.StringMapping) || getObjectFlags(t) & (ObjectFlags.ClassOrInterface | ObjectFlags.Reference)) { + return t.symbol; + } + return undefined; + } + + function compareTupleTypes(t1: TupleType, t2: TupleType): number { + if (t1 === t2) { + return 0; + } + if (t1.readonly === t2.readonly) { + return t1.readonly ? 1 : -1; + } + if (t1.elementFlags.length !== t2.elementFlags.length) { + return t1.elementFlags.length - t2.elementFlags.length; + } + for (let i = 0; i < t1.elementFlags.length; i++) { + const c = t1.elementFlags[i] - t2.elementFlags[i]; + if (c !== 0) { + return c; + } + } + for (let i = 0; i < (t1.labeledElementDeclarations?.length ?? 0); i++) { + const c = compareElementLabels(t1.labeledElementDeclarations![i], t2.labeledElementDeclarations![i]); + if (c !== 0) { + return c; + } + } + return 0; + } + + function compareElementLabels(n1: NamedTupleMember | ParameterDeclaration | undefined, n2: NamedTupleMember | ParameterDeclaration | undefined): number { + if (n1 === n2) { + return 0; + } + if (n1 === undefined) { + return -1; + } + if (n2 === undefined) { + return 1; + } + return compareComparableValues((n1.name as Identifier).escapedText as string, (n2.name as Identifier).escapedText as string); + } + + function compareTypeLists(s1: readonly Type[] | undefined, s2: readonly Type[] | undefined): number { + if (length(s1) !== length(s2)) { + return length(s1) - length(s2); + } + for (let i = 0; i < length(s1); i++) { + const c = compareTypes(s1![i], s2?.[i]); + if (c !== 0) return c; + } + return 0; + } + + function compareTypeMappers(m1: TypeMapper | undefined, m2: TypeMapper | undefined): number { + if (m1 === m2) { + return 0; + } + if (m1 === undefined) { + return 1; + } + if (m2 === undefined) { + return -1; + } + const kind1 = m1.kind; + const kind2 = m2.kind; + if (kind1 !== kind2) { + return kind1 - kind2; + } + switch (kind1) { + case TypeMapKind.Simple: { + const c = compareTypes(m1.source, (m2 as typeof m1).source); + if (c !== 0) { + return c; + } + return compareTypes(m1.target, (m2 as typeof m1).target); + } + case TypeMapKind.Array: { + const c = compareTypeLists(m1.sources, (m2 as typeof m1).sources); + if (c !== 0) { + return c; + } + return compareTypeLists(m1.targets, (m2 as typeof m1).targets); + } + case TypeMapKind.Merged: { + const c = compareTypeMappers(m1.mapper1, (m2 as typeof m1).mapper1); + if (c !== 0) { + return c; + } + return compareTypeMappers(m1.mapper2, (m2 as typeof m1).mapper2); + } + } + return 0; + } } function isNotAccessor(declaration: Declaration): boolean { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index ef83fefd533e0..89c468344fcb3 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1209,7 +1209,7 @@ export function binarySearchKey(array: readonly T[], key: U, keySelector: while (low <= high) { const middle = low + ((high - low) >> 1); const midKey = keySelector(array[middle], middle); - switch (keyComparer(midKey, key)) { + switch (Math.sign(keyComparer(midKey, key))) { case Comparison.LessThan: low = middle + 1; break; @@ -1967,9 +1967,11 @@ export function equateStringsCaseSensitive(a: string, b: string): boolean { return equateValues(a, b); } -function compareComparableValues(a: string | undefined, b: string | undefined): Comparison; -function compareComparableValues(a: number | undefined, b: number | undefined): Comparison; -function compareComparableValues(a: string | number | undefined, b: string | number | undefined) { +/** @internal */ +export function compareComparableValues(a: string | undefined, b: string | undefined): Comparison; +/** @internal */ +export function compareComparableValues(a: number | undefined, b: number | undefined): Comparison; +export function compareComparableValues(a: string | number | undefined, b: string | number | undefined) { return a === b ? Comparison.EqualTo : a === undefined ? Comparison.LessThan : b === undefined ? Comparison.GreaterThan : diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 342c0f2af7146..8f6190812b140 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -6269,21 +6269,21 @@ export interface SerializedTypeEntry { export const enum TypeFlags { Any = 1 << 0, Unknown = 1 << 1, - String = 1 << 2, - Number = 1 << 3, - Boolean = 1 << 4, - Enum = 1 << 5, // Numeric computed enum member value - BigInt = 1 << 6, - StringLiteral = 1 << 7, - NumberLiteral = 1 << 8, - BooleanLiteral = 1 << 9, - EnumLiteral = 1 << 10, // Always combined with StringLiteral, NumberLiteral, or Union - BigIntLiteral = 1 << 11, - ESSymbol = 1 << 12, // Type of symbol primitive introduced in ES6 - UniqueESSymbol = 1 << 13, // unique symbol - Void = 1 << 14, - Undefined = 1 << 15, - Null = 1 << 16, + Undefined = 1 << 2, + Null = 1 << 3, + Void = 1 << 4, + String = 1 << 5, + Number = 1 << 6, + BigInt = 1 << 7, + Boolean = 1 << 8, + ESSymbol = 1 << 9, // Type of symbol primitive introduced in ES6 + StringLiteral = 1 << 10, + NumberLiteral = 1 << 11, + BooleanLiteral = 1 << 12, + BigIntLiteral = 1 << 13, + UniqueESSymbol = 1 << 14, // unique symbol + EnumLiteral = 1 << 15, // Always combined with StringLiteral, NumberLiteral, or Union + Enum = 1 << 16, // Numeric computed enum member value Never = 1 << 17, // Never type TypeParameter = 1 << 18, // Type parameter Object = 1 << 19, // Object type @@ -6484,15 +6484,17 @@ export const enum ObjectFlags { PropagatingFlags = ContainsWideningType | ContainsObjectOrArrayLiteral | NonInferrableType, /** @internal */ InstantiatedMapped = Mapped | Instantiated, - // Object flags that uniquely identify the kind of ObjectType - /** @internal */ - ObjectTypeKindMask = ClassOrInterface | Reference | Tuple | Anonymous | Mapped | ReverseMapped | EvolvingArray, - + // Flags that require TypeFlags.Object ContainsSpread = 1 << 21, // Object literal contains spread operation ObjectRestType = 1 << 22, // Originates in object rest declaration InstantiationExpressionType = 1 << 23, // Originates in instantiation expression SingleSignatureType = 1 << 27, // A single signature type extracted from a potentially broader type + + // Object flags that uniquely identify the kind of ObjectType + /** @internal */ + ObjectTypeKindMask = ClassOrInterface | Reference | Tuple | Anonymous | Mapped | ReverseMapped | EvolvingArray | InstantiationExpressionType | SingleSignatureType, + /** @internal */ IsClassInstanceClone = 1 << 24, // Type is a clone of a class instance type // Flags that require TypeFlags.Object and ObjectFlags.Reference diff --git a/tests/baselines/reference/TypeGuardWithArrayUnion.types b/tests/baselines/reference/TypeGuardWithArrayUnion.types index 383b3398340b9..ef44ed2880f52 100644 --- a/tests/baselines/reference/TypeGuardWithArrayUnion.types +++ b/tests/baselines/reference/TypeGuardWithArrayUnion.types @@ -13,13 +13,13 @@ class Message { function saySize(message: Message | Message[]) { >saySize : (message: Message | Message[]) => number > : ^ ^^ ^^^^^^^^^^^ ->message : Message | Message[] +>message : Message[] | Message > : ^^^^^^^^^^^^^^^^^^^ if (message instanceof Array) { >message instanceof Array : boolean > : ^^^^^^^ ->message : Message | Message[] +>message : Message[] | Message > : ^^^^^^^^^^^^^^^^^^^ >Array : ArrayConstructor > : ^^^^^^^^^^^^^^^^ diff --git a/tests/baselines/reference/TypeGuardWithEnumUnion.types b/tests/baselines/reference/TypeGuardWithEnumUnion.types index 69bf80d6428a9..28dd5f988691b 100644 --- a/tests/baselines/reference/TypeGuardWithEnumUnion.types +++ b/tests/baselines/reference/TypeGuardWithEnumUnion.types @@ -20,7 +20,7 @@ function f1(x: Color | string) { if (typeof x === "number") { >typeof x === "number" : boolean > : ^^^^^^^ ->typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : string | Color > : ^^^^^^^^^^^^^^ @@ -53,15 +53,15 @@ function f1(x: Color | string) { function f2(x: Color | string | string[]) { >f2 : (x: Color | string | string[]) => void > : ^ ^^ ^^^^^^^^^ ->x : string | Color | string[] +>x : string | string[] | Color > : ^^^^^^^^^^^^^^^^^^^^^^^^^ if (typeof x === "object") { >typeof x === "object" : boolean > : ^^^^^^^ ->typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->x : string | Color | string[] +>x : string | string[] | Color > : ^^^^^^^^^^^^^^^^^^^^^^^^^ >"object" : "object" > : ^^^^^^^^ @@ -79,9 +79,9 @@ function f2(x: Color | string | string[]) { if (typeof x === "number") { >typeof x === "number" : boolean > : ^^^^^^^ ->typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->x : string | Color | string[] +>x : string | string[] | Color > : ^^^^^^^^^^^^^^^^^^^^^^^^^ >"number" : "number" > : ^^^^^^^^ @@ -110,9 +110,9 @@ function f2(x: Color | string | string[]) { if (typeof x === "string") { >typeof x === "string" : boolean > : ^^^^^^^ ->typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->x : string | Color | string[] +>x : string | string[] | Color > : ^^^^^^^^^^^^^^^^^^^^^^^^^ >"string" : "string" > : ^^^^^^^^ @@ -129,13 +129,13 @@ function f2(x: Color | string | string[]) { } else { var b = x; ->b : Color | string[] +>b : string[] | Color > : ^^^^^^^^^^^^^^^^ ->x : Color | string[] +>x : string[] | Color > : ^^^^^^^^^^^^^^^^ var b: Color | string[]; ->b : Color | string[] +>b : string[] | Color > : ^^^^^^^^^^^^^^^^ } } diff --git a/tests/baselines/reference/ambientExportDefaultErrors.types b/tests/baselines/reference/ambientExportDefaultErrors.types index 8a94feba8dff7..fae5c247b1475 100644 --- a/tests/baselines/reference/ambientExportDefaultErrors.types +++ b/tests/baselines/reference/ambientExportDefaultErrors.types @@ -41,7 +41,7 @@ declare module "indirect" { > : ^^^^^^^^^^^^^^^^^^^^^^^^^ export default typeof Foo.default; ->typeof Foo.default : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof Foo.default : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >Foo.default : number > : ^^^^^^ @@ -58,7 +58,7 @@ declare module "indirect2" { > : ^^^^^^^^^^^^^^^^^^^^^^^^^^ export = typeof Foo2; ->typeof Foo2 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof Foo2 : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >Foo2 : number > : ^^^^^^ diff --git a/tests/baselines/reference/anonymousClassExpression1.types b/tests/baselines/reference/anonymousClassExpression1.types index 246a0a1ae1bbc..0b4f4c413c76c 100644 --- a/tests/baselines/reference/anonymousClassExpression1.types +++ b/tests/baselines/reference/anonymousClassExpression1.types @@ -8,7 +8,7 @@ function f() { return typeof class {} === "function"; >typeof class {} === "function" : boolean > : ^^^^^^^ ->typeof class {} : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof class {} : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >class {} : typeof (Anonymous class) > : ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 2531c9ea0413d..2798e60d3d316 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -6570,21 +6570,21 @@ declare namespace ts { enum TypeFlags { Any = 1, Unknown = 2, - String = 4, - Number = 8, - Boolean = 16, - Enum = 32, - BigInt = 64, - StringLiteral = 128, - NumberLiteral = 256, - BooleanLiteral = 512, - EnumLiteral = 1024, - BigIntLiteral = 2048, - ESSymbol = 4096, - UniqueESSymbol = 8192, - Void = 16384, - Undefined = 32768, - Null = 65536, + Undefined = 4, + Null = 8, + Void = 16, + String = 32, + Number = 64, + BigInt = 128, + Boolean = 256, + ESSymbol = 512, + StringLiteral = 1024, + NumberLiteral = 2048, + BooleanLiteral = 4096, + BigIntLiteral = 8192, + UniqueESSymbol = 16384, + EnumLiteral = 32768, + Enum = 65536, Never = 131072, TypeParameter = 262144, Object = 524288, @@ -6597,18 +6597,18 @@ declare namespace ts { NonPrimitive = 67108864, TemplateLiteral = 134217728, StringMapping = 268435456, - Literal = 2944, - Unit = 109472, - Freshable = 2976, - StringOrNumberLiteral = 384, - PossiblyFalsy = 117724, - StringLike = 402653316, - NumberLike = 296, - BigIntLike = 2112, - BooleanLike = 528, - EnumLike = 1056, - ESSymbolLike = 12288, - VoidLike = 49152, + Literal = 15360, + Unit = 97292, + Freshable = 80896, + StringOrNumberLiteral = 3072, + PossiblyFalsy = 15868, + StringLike = 402654240, + NumberLike = 67648, + BigIntLike = 8320, + BooleanLike = 4352, + EnumLike = 98304, + ESSymbolLike = 16896, + VoidLike = 20, UnionOrIntersection = 3145728, StructuredType = 3670016, TypeVariable = 8650752, @@ -6616,7 +6616,7 @@ declare namespace ts { InstantiablePrimitive = 406847488, Instantiable = 465829888, StructuredOrInstantiable = 469499904, - Narrowable = 536624127, + Narrowable = 536707043, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { diff --git a/tests/baselines/reference/arrayBestCommonTypes.types b/tests/baselines/reference/arrayBestCommonTypes.types index 2ed7f2c9d8fa3..35627721ca563 100644 --- a/tests/baselines/reference/arrayBestCommonTypes.types +++ b/tests/baselines/reference/arrayBestCommonTypes.types @@ -620,10 +620,10 @@ module EmptyTypes { > : ^^^^^^^^^^^^ var b1 = [baseObj, base2Obj, ifaceObj]; ->b1 : iface[] -> : ^^^^^^^ ->[baseObj, base2Obj, ifaceObj] : iface[] -> : ^^^^^^^ +>b1 : (base | base2)[] +> : ^^^^^^^^^^^^^^^^ +>[baseObj, base2Obj, ifaceObj] : (base | base2)[] +> : ^^^^^^^^^^^^^^^^ >baseObj : base > : ^^^^ >base2Obj : base2 @@ -632,10 +632,10 @@ module EmptyTypes { > : ^^^^^ var b2 = [base2Obj, baseObj, ifaceObj]; ->b2 : iface[] -> : ^^^^^^^ ->[base2Obj, baseObj, ifaceObj] : iface[] -> : ^^^^^^^ +>b2 : (base | base2)[] +> : ^^^^^^^^^^^^^^^^ +>[base2Obj, baseObj, ifaceObj] : (base | base2)[] +> : ^^^^^^^^^^^^^^^^ >base2Obj : base2 > : ^^^^^ >baseObj : base @@ -644,10 +644,10 @@ module EmptyTypes { > : ^^^^^ var b3 = [baseObj, ifaceObj, base2Obj]; ->b3 : iface[] -> : ^^^^^^^ ->[baseObj, ifaceObj, base2Obj] : iface[] -> : ^^^^^^^ +>b3 : (base | base2)[] +> : ^^^^^^^^^^^^^^^^ +>[baseObj, ifaceObj, base2Obj] : (base | base2)[] +> : ^^^^^^^^^^^^^^^^ >baseObj : base > : ^^^^ >ifaceObj : iface @@ -656,10 +656,10 @@ module EmptyTypes { > : ^^^^^ var b4 = [ifaceObj, baseObj, base2Obj]; ->b4 : iface[] -> : ^^^^^^^ ->[ifaceObj, baseObj, base2Obj] : iface[] -> : ^^^^^^^ +>b4 : (base | base2)[] +> : ^^^^^^^^^^^^^^^^ +>[ifaceObj, baseObj, base2Obj] : (base | base2)[] +> : ^^^^^^^^^^^^^^^^ >ifaceObj : iface > : ^^^^^ >baseObj : base diff --git a/tests/baselines/reference/arrayConcat3.types b/tests/baselines/reference/arrayConcat3.types index 7903cd79dcbc9..5b065df162661 100644 --- a/tests/baselines/reference/arrayConcat3.types +++ b/tests/baselines/reference/arrayConcat3.types @@ -19,11 +19,11 @@ function doStuff(a: Array>, b: Arrayb.concat(a) : Fn[] > : ^^^^^^^^ ->b.concat : { (...items: ConcatArray>[]): Fn[]; (...items: (Fn | ConcatArray>)[]): Fn[]; } +>b.concat : { (...items: ConcatArray>[]): Fn[]; (...items: (ConcatArray> | Fn)[]): Fn[]; } > : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >b : Fn[] > : ^^^^^^^^ ->concat : { (...items: ConcatArray>[]): Fn[]; (...items: (Fn | ConcatArray>)[]): Fn[]; } +>concat : { (...items: ConcatArray>[]): Fn[]; (...items: (ConcatArray> | Fn)[]): Fn[]; } > : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >a : Fn[] > : ^^^^^^^ diff --git a/tests/baselines/reference/arrayDestructuringInSwitch1.types b/tests/baselines/reference/arrayDestructuringInSwitch1.types index ec8ad2209e0b2..dc9e0a9041e6f 100644 --- a/tests/baselines/reference/arrayDestructuringInSwitch1.types +++ b/tests/baselines/reference/arrayDestructuringInSwitch1.types @@ -97,7 +97,7 @@ export function evaluate(expression: Expression): boolean { return expression === 'true'; >expression === 'true' : boolean > : ^^^^^^^ ->expression : "true" | "false" +>expression : "false" | "true" > : ^^^^^^^^^^^^^^^^ >'true' : "true" > : ^^^^^^ diff --git a/tests/baselines/reference/arrayEvery.types b/tests/baselines/reference/arrayEvery.types index 6210757b88e8a..7e05640404244 100644 --- a/tests/baselines/reference/arrayEvery.types +++ b/tests/baselines/reference/arrayEvery.types @@ -18,7 +18,7 @@ const isString = (x: unknown): x is string => typeof x === 'string'; > : ^^^^^^^ >typeof x === 'string' : boolean > : ^^^^^^^ ->typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : unknown > : ^^^^^^^ diff --git a/tests/baselines/reference/arrayFind.types b/tests/baselines/reference/arrayFind.types index b1f9aff8e6429..9d8792e1259a6 100644 --- a/tests/baselines/reference/arrayFind.types +++ b/tests/baselines/reference/arrayFind.types @@ -10,7 +10,7 @@ function isNumber(x: any): x is number { return typeof x === "number"; >typeof x === "number" : boolean > : ^^^^^^^ ->typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : any >"number" : "number" diff --git a/tests/baselines/reference/arrayFlatNoCrashInference.types b/tests/baselines/reference/arrayFlatNoCrashInference.types index 8bbd51bbd00f1..dbdac3d883728 100644 --- a/tests/baselines/reference/arrayFlatNoCrashInference.types +++ b/tests/baselines/reference/arrayFlatNoCrashInference.types @@ -2,7 +2,7 @@ === arrayFlatNoCrashInference.ts === function foo(arr: T[], depth: number) { ->foo : (arr: T[], depth: number) => FlatArray[] +>foo : (arr: T[], depth: number) => FlatArray[] > : ^ ^^ ^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >arr : T[] > : ^^^ @@ -10,7 +10,7 @@ function foo(arr: T[], depth: number) { > : ^^^^^^ return arr.flat(depth); ->arr.flat(depth) : FlatArray[] +>arr.flat(depth) : FlatArray[] > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >arr.flat : (this: A, depth?: D | undefined) => FlatArray[] > : ^ ^^ ^^^^^^^^^ ^^^^^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/baselines/reference/arrayFlatNoCrashInferenceDeclarations.js b/tests/baselines/reference/arrayFlatNoCrashInferenceDeclarations.js index 1ff74edb7d62d..b5aaeaed996aa 100644 --- a/tests/baselines/reference/arrayFlatNoCrashInferenceDeclarations.js +++ b/tests/baselines/reference/arrayFlatNoCrashInferenceDeclarations.js @@ -13,4 +13,4 @@ function foo(arr, depth) { //// [arrayFlatNoCrashInferenceDeclarations.d.ts] -declare function foo(arr: T[], depth: number): FlatArray[]; +declare function foo(arr: T[], depth: number): FlatArray[]; diff --git a/tests/baselines/reference/arrayFlatNoCrashInferenceDeclarations.types b/tests/baselines/reference/arrayFlatNoCrashInferenceDeclarations.types index 05081a3f9f0cc..25e6945200d2b 100644 --- a/tests/baselines/reference/arrayFlatNoCrashInferenceDeclarations.types +++ b/tests/baselines/reference/arrayFlatNoCrashInferenceDeclarations.types @@ -2,7 +2,7 @@ === arrayFlatNoCrashInferenceDeclarations.ts === function foo(arr: T[], depth: number) { ->foo : (arr: T[], depth: number) => FlatArray[] +>foo : (arr: T[], depth: number) => FlatArray[] > : ^ ^^ ^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >arr : T[] > : ^^^ @@ -10,7 +10,7 @@ function foo(arr: T[], depth: number) { > : ^^^^^^ return arr.flat(depth); ->arr.flat(depth) : FlatArray[] +>arr.flat(depth) : FlatArray[] > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >arr.flat : (this: A, depth?: D | undefined) => FlatArray[] > : ^ ^^ ^^^^^^^^^ ^^^^^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/baselines/reference/arrayLiteralComments.types b/tests/baselines/reference/arrayLiteralComments.types index 66fb48f01742f..f1f2576fbb239 100644 --- a/tests/baselines/reference/arrayLiteralComments.types +++ b/tests/baselines/reference/arrayLiteralComments.types @@ -2,9 +2,9 @@ === arrayLiteralComments.ts === var testArrayWithFunc = [ ->testArrayWithFunc : (string | number | (() => void) | number[] | { a: number; })[] +>testArrayWithFunc : (string | number | number[] | (() => void) | { a: number; })[] > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->[ // Function comment function() { let x = 1; }, // String comment '1', // Numeric comment 2, // Object comment { a: 1 }, // Array comment [1, 2, 3]] : (string | number | (() => void) | number[] | { a: number; })[] +>[ // Function comment function() { let x = 1; }, // String comment '1', // Numeric comment 2, // Object comment { a: 1 }, // Array comment [1, 2, 3]] : (string | number | number[] | (() => void) | { a: number; })[] > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // Function comment diff --git a/tests/baselines/reference/arrayLiteralContextualType.types b/tests/baselines/reference/arrayLiteralContextualType.types index 584ba43dd83e1..c3b433fdfc4e7 100644 --- a/tests/baselines/reference/arrayLiteralContextualType.types +++ b/tests/baselines/reference/arrayLiteralContextualType.types @@ -60,7 +60,7 @@ foo([ > : ^^^^ >foo : (animals: IAnimal[]) => void > : ^ ^^ ^^^^^^^^^ ->[ new Giraffe(), new Elephant()] : (Giraffe | Elephant)[] +>[ new Giraffe(), new Elephant()] : (Elephant | Giraffe)[] > : ^^^^^^^^^^^^^^^^^^^^^^ new Giraffe(), @@ -81,7 +81,7 @@ bar([ > : ^^^^ >bar : (animals: { [n: number]: IAnimal; }) => void > : ^ ^^ ^^^^^^^^^ ->[ new Giraffe(), new Elephant()] : (Giraffe | Elephant)[] +>[ new Giraffe(), new Elephant()] : (Elephant | Giraffe)[] > : ^^^^^^^^^^^^^^^^^^^^^^ new Giraffe(), @@ -99,9 +99,9 @@ bar([ ]); // Legal because of the contextual type IAnimal provided by the parameter var arr = [new Giraffe(), new Elephant()]; ->arr : (Giraffe | Elephant)[] +>arr : (Elephant | Giraffe)[] > : ^^^^^^^^^^^^^^^^^^^^^^ ->[new Giraffe(), new Elephant()] : (Giraffe | Elephant)[] +>[new Giraffe(), new Elephant()] : (Elephant | Giraffe)[] > : ^^^^^^^^^^^^^^^^^^^^^^ >new Giraffe() : Giraffe > : ^^^^^^^ @@ -117,7 +117,7 @@ foo(arr); // ok because arr is Array not {}[] > : ^^^^ >foo : (animals: IAnimal[]) => void > : ^ ^^ ^^^^^^^^^ ->arr : (Giraffe | Elephant)[] +>arr : (Elephant | Giraffe)[] > : ^^^^^^^^^^^^^^^^^^^^^^ bar(arr); // ok because arr is Array not {}[] @@ -125,6 +125,6 @@ bar(arr); // ok because arr is Array not {}[] > : ^^^^ >bar : (animals: { [n: number]: IAnimal; }) => void > : ^ ^^ ^^^^^^^^^ ->arr : (Giraffe | Elephant)[] +>arr : (Elephant | Giraffe)[] > : ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/baselines/reference/arrayLiteralInference.types b/tests/baselines/reference/arrayLiteralInference.types index 6520794bbf907..6464795a1ea43 100644 --- a/tests/baselines/reference/arrayLiteralInference.types +++ b/tests/baselines/reference/arrayLiteralInference.types @@ -94,7 +94,7 @@ const appTypeStylesWithError: Map> = new Map([ > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >Map : MapConstructor > : ^^^^^^^^^^^^^^ ->[ [AppType.Standard, [AppStyle.Standard, AppStyle.MiniApp]], [AppType.Relationship, [AppStyle.Standard, AppStyle.Tree, AppStyle.TreeEntity]], [AppType.AdvancedList, [AppStyle.Standard, AppStyle.MiniApp]]] : ([AppType.Standard, (AppStyle.Standard | AppStyle.MiniApp)[]] | [AppType.Relationship, (AppStyle.Tree | AppStyle.TreeEntity | AppStyle.Standard)[]] | [AppType.AdvancedList, (AppStyle.Standard | AppStyle.MiniApp)[]])[] +>[ [AppType.Standard, [AppStyle.Standard, AppStyle.MiniApp]], [AppType.Relationship, [AppStyle.Standard, AppStyle.Tree, AppStyle.TreeEntity]], [AppType.AdvancedList, [AppStyle.Standard, AppStyle.MiniApp]]] : ([AppType.AdvancedList, (AppStyle.Standard | AppStyle.MiniApp)[]] | [AppType.Standard, (AppStyle.Standard | AppStyle.MiniApp)[]] | [AppType.Relationship, (AppStyle.Tree | AppStyle.TreeEntity | AppStyle.Standard)[]])[] > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [AppType.Standard, [AppStyle.Standard, AppStyle.MiniApp]], @@ -210,7 +210,7 @@ let b1: { x: boolean }[] = foo({ x: true }, { x: false }); let b2: boolean[][] = foo([true], [false]); >b2 : boolean[][] > : ^^^^^^^^^^^ ->foo([true], [false]) : (true[] | false[])[] +>foo([true], [false]) : (false[] | true[])[] > : ^^^^^^^^^^^^^^^^^^^^ >foo : (...args: T[]) => T[] > : ^ ^^^^^ ^^ ^^^^^ diff --git a/tests/baselines/reference/arrayLiterals.types b/tests/baselines/reference/arrayLiterals.types index 5b4d21f2acf5b..7198be6ca0aae 100644 --- a/tests/baselines/reference/arrayLiterals.types +++ b/tests/baselines/reference/arrayLiterals.types @@ -4,9 +4,9 @@ // Empty array literal with no contextual type has type Undefined[] var arr1= [[], [1], ['']]; ->arr1 : (number[] | string[])[] +>arr1 : (string[] | number[])[] > : ^^^^^^^^^^^^^^^^^^^^^^^ ->[[], [1], ['']] : (number[] | string[])[] +>[[], [1], ['']] : (string[] | number[])[] > : ^^^^^^^^^^^^^^^^^^^^^^^ >[] : undefined[] > : ^^^^^^^^^^^ @@ -20,9 +20,9 @@ var arr1= [[], [1], ['']]; > : ^^ var arr2 = [[null], [1], ['']]; ->arr2 : (number[] | string[])[] +>arr2 : (string[] | number[])[] > : ^^^^^^^^^^^^^^^^^^^^^^^ ->[[null], [1], ['']] : (number[] | string[])[] +>[[null], [1], ['']] : (string[] | number[])[] > : ^^^^^^^^^^^^^^^^^^^^^^^ >[null] : null[] > : ^^^^^^ diff --git a/tests/baselines/reference/arrayLiterals3.types b/tests/baselines/reference/arrayLiterals3.types index a1ea1c432147b..e497a1e9d8936 100644 --- a/tests/baselines/reference/arrayLiterals3.types +++ b/tests/baselines/reference/arrayLiterals3.types @@ -97,11 +97,11 @@ var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; interface tup { 0: number[]|string[]; ->0 : number[] | string[] +>0 : string[] | number[] > : ^^^^^^^^^^^^^^^^^^^ 1: number[]|string[]; ->1 : number[] | string[] +>1 : string[] | number[] > : ^^^^^^^^^^^^^^^^^^^ } interface myArray extends Array { } @@ -111,7 +111,7 @@ var c0: tup = [...temp2]; // Error > : ^^^ >[...temp2] : [number[], string[]] > : ^^^^^^^^^^^^^^^^^^^^ ->...temp2 : number[] | string[] +>...temp2 : string[] | number[] > : ^^^^^^^^^^^^^^^^^^^ >temp2 : [number[], string[]] > : ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types index 5714861176f3f..167ac8d002a9f 100644 --- a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types +++ b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types @@ -63,9 +63,9 @@ var xs = [list, myList]; // {}[] > : ^^^^^^^^^^^^^^ var ys = [list, list2]; // {}[] ->ys : (List | List)[] +>ys : (List | List)[] > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->[list, list2] : (List | List)[] +>[list, list2] : (List | List)[] > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >list : List > : ^^^^^^^^^^^^ diff --git a/tests/baselines/reference/arrayconcat.types b/tests/baselines/reference/arrayconcat.types index 6cdcb06d06a7f..99de888cfc398 100644 --- a/tests/baselines/reference/arrayconcat.types +++ b/tests/baselines/reference/arrayconcat.types @@ -66,7 +66,7 @@ class parser { > : ^^^^^^^^^^ >sort : (compareFn?: (a: IOptions, b: IOptions) => number) => IOptions[] > : ^ ^^^^ ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ->function(a, b) { var aName = a.name.toLowerCase(); var bName = b.name.toLowerCase(); if (aName > bName) { return 1; } else if (aName < bName) { return -1; } else { return 0; } } : (a: IOptions, b: IOptions) => 1 | -1 | 0 +>function(a, b) { var aName = a.name.toLowerCase(); var bName = b.name.toLowerCase(); if (aName > bName) { return 1; } else if (aName < bName) { return -1; } else { return 0; } } : (a: IOptions, b: IOptions) => -1 | 0 | 1 > : ^ ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ >a : IOptions > : ^^^^^^^^ diff --git a/tests/baselines/reference/arrowFunctionParsingDoesNotConfuseParenthesizedObjectForArrowHead.types b/tests/baselines/reference/arrowFunctionParsingDoesNotConfuseParenthesizedObjectForArrowHead.types index e7999a9ef5b9c..17412ef75b596 100644 --- a/tests/baselines/reference/arrowFunctionParsingDoesNotConfuseParenthesizedObjectForArrowHead.types +++ b/tests/baselines/reference/arrowFunctionParsingDoesNotConfuseParenthesizedObjectForArrowHead.types @@ -10,13 +10,13 @@ declare var a: any; >a : any const test = () => ({ ->test : () => { prop: boolean; run: () => "special" | "default"; } +>test : () => { prop: boolean; run: () => "default" | "special"; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->() => ({ // "Identifier expected." error on "!" and two "Duplicate identifier '(Missing)'." errors on space. prop: !value, // remove ! to see that errors will be gone run: () => { //replace arrow function with regular function to see that errors will be gone // comment next line or remove "()" to see that errors will be gone if(!a.b()) { return 'special'; } return 'default'; }}) : () => { prop: boolean; run: () => "special" | "default"; } +>() => ({ // "Identifier expected." error on "!" and two "Duplicate identifier '(Missing)'." errors on space. prop: !value, // remove ! to see that errors will be gone run: () => { //replace arrow function with regular function to see that errors will be gone // comment next line or remove "()" to see that errors will be gone if(!a.b()) { return 'special'; } return 'default'; }}) : () => { prop: boolean; run: () => "default" | "special"; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->({ // "Identifier expected." error on "!" and two "Duplicate identifier '(Missing)'." errors on space. prop: !value, // remove ! to see that errors will be gone run: () => { //replace arrow function with regular function to see that errors will be gone // comment next line or remove "()" to see that errors will be gone if(!a.b()) { return 'special'; } return 'default'; }}) : { prop: boolean; run: () => "special" | "default"; } +>({ // "Identifier expected." error on "!" and two "Duplicate identifier '(Missing)'." errors on space. prop: !value, // remove ! to see that errors will be gone run: () => { //replace arrow function with regular function to see that errors will be gone // comment next line or remove "()" to see that errors will be gone if(!a.b()) { return 'special'; } return 'default'; }}) : { prop: boolean; run: () => "default" | "special"; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->{ // "Identifier expected." error on "!" and two "Duplicate identifier '(Missing)'." errors on space. prop: !value, // remove ! to see that errors will be gone run: () => { //replace arrow function with regular function to see that errors will be gone // comment next line or remove "()" to see that errors will be gone if(!a.b()) { return 'special'; } return 'default'; }} : { prop: boolean; run: () => "special" | "default"; } +>{ // "Identifier expected." error on "!" and two "Duplicate identifier '(Missing)'." errors on space. prop: !value, // remove ! to see that errors will be gone run: () => { //replace arrow function with regular function to see that errors will be gone // comment next line or remove "()" to see that errors will be gone if(!a.b()) { return 'special'; } return 'default'; }} : { prop: boolean; run: () => "default" | "special"; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // "Identifier expected." error on "!" and two "Duplicate identifier '(Missing)'." errors on space. @@ -29,9 +29,9 @@ const test = () => ({ > : ^^^^^^^ run: () => { //replace arrow function with regular function to see that errors will be gone ->run : () => "special" | "default" +>run : () => "default" | "special" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->() => { //replace arrow function with regular function to see that errors will be gone // comment next line or remove "()" to see that errors will be gone if(!a.b()) { return 'special'; } return 'default'; } : () => "special" | "default" +>() => { //replace arrow function with regular function to see that errors will be gone // comment next line or remove "()" to see that errors will be gone if(!a.b()) { return 'special'; } return 'default'; } : () => "default" | "special" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ // comment next line or remove "()" to see that errors will be gone diff --git a/tests/baselines/reference/assertionTypePredicates1.types b/tests/baselines/reference/assertionTypePredicates1.types index fe938414d516e..85c17e8586c08 100644 --- a/tests/baselines/reference/assertionTypePredicates1.types +++ b/tests/baselines/reference/assertionTypePredicates1.types @@ -62,7 +62,7 @@ function f01(x: unknown) { > : ^ ^^ ^^^^^ >typeof x === "string" : boolean > : ^^^^^^^ ->typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : unknown > : ^^^^^^^ @@ -122,7 +122,7 @@ function f01(x: unknown) { > : ^^^^^^^ >typeof x === "boolean" : boolean > : ^^^^^^^ ->typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : unknown > : ^^^^^^^ @@ -130,7 +130,7 @@ function f01(x: unknown) { > : ^^^^^^^^^ >typeof x === "number" : boolean > : ^^^^^^^ ->typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : unknown > : ^^^^^^^ @@ -138,12 +138,12 @@ function f01(x: unknown) { > : ^^^^^^^^ x.toLocaleString; ->x.toLocaleString : ((locales?: string | string[], options?: Intl.NumberFormatOptions) => string) | (() => string) -> : ^^ ^^^ ^^ ^^^ ^^^^^ ^^^^^^^^^^^ ^ +>x.toLocaleString : (() => string) | ((locales?: string | string[], options?: Intl.NumberFormatOptions) => string) +> : ^^^^^^^ ^^^^^^ ^^^ ^^ ^^^ ^^^^^ ^ >x : number | boolean > : ^^^^^^^^^^^^^^^^ ->toLocaleString : ((locales?: string | string[], options?: Intl.NumberFormatOptions) => string) | (() => string) -> : ^^ ^^^ ^^ ^^^ ^^^^^ ^^^^^^^^^^^ ^ +>toLocaleString : (() => string) | ((locales?: string | string[], options?: Intl.NumberFormatOptions) => string) +> : ^^^^^^^ ^^^^^^ ^^^ ^^ ^^^ ^^^^^ ^ } if (!!true) { >!!true : true @@ -248,7 +248,7 @@ function f01(x: unknown) { > : ^^^^^^^^^ >typeof x === "string" : boolean > : ^^^^^^^ ->typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : {} | null > : ^^^^^^^^^ @@ -672,7 +672,7 @@ class Test { > : ^ ^^ ^^^^^ >typeof x === "string" : boolean > : ^^^^^^^ ->typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : unknown > : ^^^^^^^ @@ -783,7 +783,7 @@ class Derived extends Test { > : ^ ^^ ^^^^^ >typeof x === "string" : boolean > : ^^^^^^^ ->typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : unknown > : ^^^^^^^ @@ -938,7 +938,7 @@ function f20(x: unknown) { > : ^ ^^ ^^^^^ >typeof x === "string" : boolean > : ^^^^^^^ ->typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : unknown > : ^^^^^^^ @@ -964,7 +964,7 @@ function f20(x: unknown) { > : ^ >typeof x === "string" : boolean > : ^^^^^^^ ->typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : unknown > : ^^^^^^^ @@ -990,7 +990,7 @@ function f20(x: unknown) { > : ^ ^^ ^^^^^ >typeof x === "string" : boolean > : ^^^^^^^ ->typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : unknown > : ^^^^^^^ @@ -1016,7 +1016,7 @@ function f20(x: unknown) { > : ^ ^^ ^^^^^ >typeof x === "string" : boolean > : ^^^^^^^ ->typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : unknown > : ^^^^^^^ diff --git a/tests/baselines/reference/assertionsAndNonReturningFunctions.types b/tests/baselines/reference/assertionsAndNonReturningFunctions.types index f93528300f054..33b7c02337684 100644 --- a/tests/baselines/reference/assertionsAndNonReturningFunctions.types +++ b/tests/baselines/reference/assertionsAndNonReturningFunctions.types @@ -37,7 +37,7 @@ function assertIsString(x) { > : ^^^^^^^ >typeof x === "string" : boolean > : ^^^^^^^ ->typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : unknown > : ^^^^^^^ @@ -108,7 +108,7 @@ function f1(x) { > : ^^^^^^^^^^ >typeof x === "string" : boolean > : ^^^^^^^ ->typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : any > : ^^^ @@ -138,7 +138,7 @@ function f1(x) { > : ^ ^^ ^^^^^ >typeof x === "string" : boolean > : ^^^^^^^ ->typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : any > : ^^^ @@ -201,7 +201,7 @@ function f1(x) { * @param {boolean} b */ function f2(b) { ->f2 : (b: boolean) => 1 | 0 +>f2 : (b: boolean) => 0 | 1 > : ^ ^^ ^^^^^^^^^^ >b : boolean > : ^^^^^^^ diff --git a/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.errors.txt b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.errors.txt index 91f79a95e46a5..0fa09776f5924 100644 --- a/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.errors.txt @@ -1,11 +1,11 @@ assignmentCompatWithDiscriminatedUnion.ts(44,5): error TS2322: Type 'S' is not assignable to type 'T'. - Type 'S' is not assignable to type '{ a: 0; b: 4 | 1; }'. + Type 'S' is not assignable to type '{ a: 0; b: 1 | 4; }'. Types of property 'a' are incompatible. Type '0 | 2' is not assignable to type '0'. Type '2' is not assignable to type '0'. assignmentCompatWithDiscriminatedUnion.ts(58,5): error TS2322: Type 'S' is not assignable to type 'T'. - Type 'S' is not assignable to type '{ a: 0; b: 4 | 1; } | { a: 2; b: 4 | 3; c: string; }'. - Property 'c' is missing in type 'S' but required in type '{ a: 2; b: 4 | 3; c: string; }'. + Type 'S' is not assignable to type '{ a: 0; b: 1 | 4; } | { a: 2; b: 3 | 4; c: string; }'. + Property 'c' is missing in type 'S' but required in type '{ a: 2; b: 3 | 4; c: string; }'. assignmentCompatWithDiscriminatedUnion.ts(82,5): error TS2322: Type 'S' is not assignable to type 'T'. Type 'S' is not assignable to type '{ a: N; b: N; c: 2; }'. Types of property 'c' are incompatible. @@ -60,7 +60,7 @@ assignmentCompatWithDiscriminatedUnion.ts(82,5): error TS2322: Type 'S' is not a t = s; ~ !!! error TS2322: Type 'S' is not assignable to type 'T'. -!!! error TS2322: Type 'S' is not assignable to type '{ a: 0; b: 4 | 1; }'. +!!! error TS2322: Type 'S' is not assignable to type '{ a: 0; b: 1 | 4; }'. !!! error TS2322: Types of property 'a' are incompatible. !!! error TS2322: Type '0 | 2' is not assignable to type '0'. !!! error TS2322: Type '2' is not assignable to type '0'. @@ -80,8 +80,8 @@ assignmentCompatWithDiscriminatedUnion.ts(82,5): error TS2322: Type 'S' is not a t = s; ~ !!! error TS2322: Type 'S' is not assignable to type 'T'. -!!! error TS2322: Type 'S' is not assignable to type '{ a: 0; b: 4 | 1; } | { a: 2; b: 4 | 3; c: string; }'. -!!! error TS2322: Property 'c' is missing in type 'S' but required in type '{ a: 2; b: 4 | 3; c: string; }'. +!!! error TS2322: Type 'S' is not assignable to type '{ a: 0; b: 1 | 4; } | { a: 2; b: 3 | 4; c: string; }'. +!!! error TS2322: Property 'c' is missing in type 'S' but required in type '{ a: 2; b: 3 | 4; c: string; }'. !!! related TS2728 assignmentCompatWithDiscriminatedUnion.ts:52:36: 'c' is declared here. } diff --git a/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.symbols b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.symbols index e52ea8f834394..ea3204ddb477c 100644 --- a/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.symbols +++ b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.symbols @@ -383,9 +383,9 @@ namespace GH12052 { >undefined : Symbol(undefined) good.type = getAxisType(); ->good.type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 123, 27), Decl(assignmentCompatWithDiscriminatedUnion.ts, 125, 32)) +>good.type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 125, 32), Decl(assignmentCompatWithDiscriminatedUnion.ts, 123, 27)) >good : Symbol(good, Decl(assignmentCompatWithDiscriminatedUnion.ts, 139, 9)) ->type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 123, 27), Decl(assignmentCompatWithDiscriminatedUnion.ts, 125, 32)) +>type : Symbol(type, Decl(assignmentCompatWithDiscriminatedUnion.ts, 125, 32), Decl(assignmentCompatWithDiscriminatedUnion.ts, 123, 27)) >getAxisType : Symbol(getAxisType, Decl(assignmentCompatWithDiscriminatedUnion.ts, 128, 46)) } diff --git a/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.types b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.types index be6617683be64..128a7b8948bba 100644 --- a/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.types +++ b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.types @@ -73,7 +73,7 @@ namespace Example2 { > : ^ >a : 0 > : ^ ->b : 4 | 1 +>b : 1 | 4 > : ^^^^^ | { a: 1, b: 2 } // T1 @@ -85,7 +85,7 @@ namespace Example2 { | { a: 2, b: 3 | 4 }; // T2 >a : 2 > : ^ ->b : 4 | 3 +>b : 3 | 4 > : ^^^^^ declare let s: S; @@ -125,7 +125,7 @@ namespace Example3 { > : ^ >a : 0 > : ^ ->b : 4 | 1 +>b : 1 | 4 > : ^^^^^ | { a: 1, b: 2 | 4 } // T1 @@ -178,7 +178,7 @@ namespace Example4 { > : ^ >a : 0 > : ^ ->b : 4 | 1 +>b : 1 | 4 > : ^^^^^ | { a: 1, b: 2 } // T1 @@ -190,7 +190,7 @@ namespace Example4 { | { a: 2, b: 3 | 4, c: string }; // T2 >a : 2 > : ^ ->b : 4 | 3 +>b : 3 | 4 > : ^^^^^ >c : string > : ^^^^^^ @@ -523,11 +523,11 @@ namespace GH12052 { good.type = getAxisType(); >good.type = getAxisType() : IAxisType > : ^^^^^^^^^ ->good.type : "linear" | "categorical" +>good.type : "categorical" | "linear" > : ^^^^^^^^^^^^^^^^^^^^^^^^ >good : IAxis > : ^^^^^ ->type : "linear" | "categorical" +>type : "categorical" | "linear" > : ^^^^^^^^^^^^^^^^^^^^^^^^ >getAxisType() : IAxisType > : ^^^^^^^^^ @@ -693,7 +693,7 @@ namespace GH39357 { const a: A = b === "a" || b === "b" ? [b, 1] : ["c", ""]; >a : A > : ^ ->b === "a" || b === "b" ? [b, 1] : ["c", ""] : ["a" | "b", number] | ["c", string] +>b === "a" || b === "b" ? [b, 1] : ["c", ""] : ["c", string] | ["a" | "b", number] > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >b === "a" || b === "b" : boolean > : ^^^^^^^ diff --git a/tests/baselines/reference/assignmentToAnyArrayRestParameters.types b/tests/baselines/reference/assignmentToAnyArrayRestParameters.types index 7d26e0601b2d1..90cc5b3cd3b76 100644 --- a/tests/baselines/reference/assignmentToAnyArrayRestParameters.types +++ b/tests/baselines/reference/assignmentToAnyArrayRestParameters.types @@ -70,7 +70,7 @@ function bar() { > : ^^^ type T02 = string[][K | "0"]; ->T02 : string[][K | "0"] +>T02 : string[]["0" | K] > : ^^^^^^^^^^^^^^^^^ type T10 = T["0"]; @@ -82,7 +82,7 @@ function bar() { > : ^^^^^^^^ type T12 = T[K | "0"]; ->T12 : T[K | "0"] +>T12 : T["0" | K] > : ^^^^^^^^^^ } diff --git a/tests/baselines/reference/asyncFunctionContextuallyTypedReturns.types b/tests/baselines/reference/asyncFunctionContextuallyTypedReturns.types index 19a78cded49dc..30bac02927d64 100644 --- a/tests/baselines/reference/asyncFunctionContextuallyTypedReturns.types +++ b/tests/baselines/reference/asyncFunctionContextuallyTypedReturns.types @@ -14,11 +14,11 @@ f(v => v ? [0] : Promise.reject()); > : ^^^^ >f : (cb: (v: boolean) => [0] | PromiseLike<[0]>) => void > : ^ ^^ ^^^^^ ->v => v ? [0] : Promise.reject() : (v: boolean) => [0] | Promise<[0]> +>v => v ? [0] : Promise.reject() : (v: boolean) => Promise<[0]> | [0] > : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >v : boolean > : ^^^^^^^ ->v ? [0] : Promise.reject() : [0] | Promise<[0]> +>v ? [0] : Promise.reject() : Promise<[0]> | [0] > : ^^^^^^^^^^^^^^^^^^ >v : boolean > : ^^^^^^^ @@ -44,7 +44,7 @@ f(async v => v ? [0] : Promise.reject()); > : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ >v : boolean > : ^^^^^^^ ->v ? [0] : Promise.reject() : [0] | Promise<[0]> +>v ? [0] : Promise.reject() : Promise<[0]> | [0] > : ^^^^^^^^^^^^^^^^^^ >v : boolean > : ^^^^^^^ @@ -136,12 +136,12 @@ h(v => v ? (abc) => { } : Promise.reject()); > : ^^^^ >h : (cb: (v: boolean) => MyCallback | PromiseLike) => void > : ^ ^^ ^^^^^ ->v => v ? (abc) => { } : Promise.reject() : (v: boolean) => ((abc: string) => void) | Promise -> : ^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>v => v ? (abc) => { } : Promise.reject() : (v: boolean) => Promise | ((abc: string) => void) +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ >v : boolean > : ^^^^^^^ ->v ? (abc) => { } : Promise.reject() : ((abc: string) => void) | Promise -> : ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>v ? (abc) => { } : Promise.reject() : Promise | ((abc: string) => void) +> : ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ >v : boolean > : ^^^^^^^ >(abc) => { } : (abc: string) => void diff --git a/tests/baselines/reference/awaitUnionPromise.types b/tests/baselines/reference/awaitUnionPromise.types index 661a2c3999cd4..efe2278ae503d 100644 --- a/tests/baselines/reference/awaitUnionPromise.types +++ b/tests/baselines/reference/awaitUnionPromise.types @@ -54,13 +54,13 @@ async function main() { > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >await x.next2() : number | AsyncEnumeratorDone > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->x.next2() : Promise | Promise +>x.next2() : Promise | Promise > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->x.next2 : () => Promise | Promise +>x.next2 : () => Promise | Promise > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : IAsyncEnumerator > : ^^^^^^^^^^^^^^^^^^^^^^^^ ->next2 : () => Promise | Promise +>next2 : () => Promise | Promise > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ let c = await x.next3(); diff --git a/tests/baselines/reference/awaitUnion_es5.types b/tests/baselines/reference/awaitUnion_es5.types index 3a2e25736983f..3be4d98e83d29 100644 --- a/tests/baselines/reference/awaitUnion_es5.types +++ b/tests/baselines/reference/awaitUnion_es5.types @@ -6,7 +6,7 @@ declare let a: number | string; > : ^^^^^^^^^^^^^^^ declare let b: PromiseLike | PromiseLike; ->b : PromiseLike | PromiseLike +>b : PromiseLike | PromiseLike > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ declare let c: PromiseLike; @@ -38,7 +38,7 @@ async function f() { > : ^^^^^^^^^^^^^^^ >await b : string | number > : ^^^^^^^^^^^^^^^ ->b : PromiseLike | PromiseLike +>b : PromiseLike | PromiseLike > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ let await_c = await c; diff --git a/tests/baselines/reference/awaitUnion_es6.types b/tests/baselines/reference/awaitUnion_es6.types index 63302416c5210..a497a07b36a7f 100644 --- a/tests/baselines/reference/awaitUnion_es6.types +++ b/tests/baselines/reference/awaitUnion_es6.types @@ -6,7 +6,7 @@ declare let a: number | string; > : ^^^^^^^^^^^^^^^ declare let b: PromiseLike | PromiseLike; ->b : PromiseLike | PromiseLike +>b : PromiseLike | PromiseLike > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ declare let c: PromiseLike; @@ -38,7 +38,7 @@ async function f() { > : ^^^^^^^^^^^^^^^ >await b : string | number > : ^^^^^^^^^^^^^^^ ->b : PromiseLike | PromiseLike +>b : PromiseLike | PromiseLike > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ let await_c = await c; diff --git a/tests/baselines/reference/awaitedTypeNoLib.errors.txt b/tests/baselines/reference/awaitedTypeNoLib.errors.txt index f19971eed35b7..58e0eb02b7206 100644 --- a/tests/baselines/reference/awaitedTypeNoLib.errors.txt +++ b/tests/baselines/reference/awaitedTypeNoLib.errors.txt @@ -8,9 +8,9 @@ error TS2318: Cannot find global type 'Object'. error TS2318: Cannot find global type 'RegExp'. error TS2318: Cannot find global type 'String'. awaitedTypeNoLib.ts(3,15): error TS2304: Cannot find name 'PromiseLike'. -awaitedTypeNoLib.ts(18,27): error TS2345: Argument of type 'NotPromise | Thenable>' is not assignable to parameter of type 'Thenable'. +awaitedTypeNoLib.ts(18,27): error TS2345: Argument of type 'Thenable> | NotPromise' is not assignable to parameter of type 'Thenable'. Type 'NotPromise' is not assignable to type 'Thenable'. - Type 'TResult | (TResult extends PromiseLike ? never : TResult)' is not assignable to type 'Thenable'. + Type '(TResult extends PromiseLike ? never : TResult) | TResult' is not assignable to type 'Thenable'. Type 'Thenable & TResult' is not assignable to type 'Thenable'. Type 'unknown' is not assignable to type 'TResult'. 'TResult' could be instantiated with an arbitrary type which could be unrelated to 'unknown'. @@ -47,9 +47,9 @@ awaitedTypeNoLib.ts(18,27): error TS2345: Argument of type 'NotPromise // #58547 This previously was a Debug Failure. False expression: type provided should not be a non-generic 'promise'-like. this.resolvePromise(result, resolve); ~~~~~~ -!!! error TS2345: Argument of type 'NotPromise | Thenable>' is not assignable to parameter of type 'Thenable'. +!!! error TS2345: Argument of type 'Thenable> | NotPromise' is not assignable to parameter of type 'Thenable'. !!! error TS2345: Type 'NotPromise' is not assignable to type 'Thenable'. -!!! error TS2345: Type 'TResult | (TResult extends PromiseLike ? never : TResult)' is not assignable to type 'Thenable'. +!!! error TS2345: Type '(TResult extends PromiseLike ? never : TResult) | TResult' is not assignable to type 'Thenable'. !!! error TS2345: Type 'Thenable & TResult' is not assignable to type 'Thenable'. !!! error TS2345: Type 'unknown' is not assignable to type 'TResult'. !!! error TS2345: 'TResult' could be instantiated with an arbitrary type which could be unrelated to 'unknown'. diff --git a/tests/baselines/reference/awaitedTypeNoLib.types b/tests/baselines/reference/awaitedTypeNoLib.types index b24d5ad4165e7..8a2bb6c3ce375 100644 --- a/tests/baselines/reference/awaitedTypeNoLib.types +++ b/tests/baselines/reference/awaitedTypeNoLib.types @@ -31,7 +31,7 @@ class Thenable { > : ^ ^^ ^^ ^^ ^^ ^^^^^^^^^ result: NotPromise | Thenable>, ->result : NotPromise | Thenable> +>result : Thenable> | NotPromise > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ resolve: Receiver, @@ -42,7 +42,7 @@ class Thenable { if (result instanceof Thenable) { >result instanceof Thenable : boolean > : ^^^^^^^ ->result : NotPromise | Thenable> +>result : Thenable> | NotPromise > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >Thenable : typeof Thenable > : ^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ class Thenable { > : ^^^^ >resolvePromise : (result: Thenable, resolve: Receiver) => void > : ^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^ ->result : NotPromise | Thenable> +>result : Thenable> | NotPromise > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >resolve : Receiver > : ^^^^^^^^^^^^^^^^^ diff --git a/tests/baselines/reference/bestChoiceType.types b/tests/baselines/reference/bestChoiceType.types index 2b0a3a974e312..a16a665bdfcd8 100644 --- a/tests/baselines/reference/bestChoiceType.types +++ b/tests/baselines/reference/bestChoiceType.types @@ -107,9 +107,9 @@ function f2() { > : ^^^^^^ let y = x ? x : []; ->y : RegExpMatchArray | never[] +>y : never[] | RegExpMatchArray > : ^^^^^^^^^^^^^^^^^^^^^^^^^^ ->x ? x : [] : RegExpMatchArray | never[] +>x ? x : [] : never[] | RegExpMatchArray > : ^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : RegExpMatchArray | null > : ^^^^^^^^^^^^^^^^^^^^^^^ @@ -125,7 +125,7 @@ function f2() { > : ^^^^^ >y.map : ((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]) | ((callbackfn: (value: never, index: number, array: never[]) => U, thisArg?: any) => U[]) > : ^^ ^^ ^^^ ^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^ ->y : RegExpMatchArray | never[] +>y : never[] | RegExpMatchArray > : ^^^^^^^^^^^^^^^^^^^^^^^^^^ >map : ((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]) | ((callbackfn: (value: never, index: number, array: never[]) => U, thisArg?: any) => U[]) > : ^^ ^^ ^^^ ^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^ diff --git a/tests/baselines/reference/bivariantInferences.types b/tests/baselines/reference/bivariantInferences.types index b291cd530e474..080e9df5077e3 100644 --- a/tests/baselines/reference/bivariantInferences.types +++ b/tests/baselines/reference/bivariantInferences.types @@ -14,11 +14,11 @@ interface Array { } declare const a: (string | number)[] | null[] | undefined[] | {}[]; ->a : (string | number)[] | null[] | undefined[] | {}[] +>a : undefined[] | null[] | {}[] | (string | number)[] > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ declare const b: (string | number)[] | null[] | undefined[] | {}[]; ->b : (string | number)[] | null[] | undefined[] | {}[] +>b : undefined[] | null[] | {}[] | (string | number)[] > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ let x = a.equalsShallow(b); @@ -28,10 +28,10 @@ let x = a.equalsShallow(b); > : ^^^^^^^ >a.equalsShallow : ((this: readonly T[], other: readonly T[]) => boolean) | ((this: readonly T[], other: readonly T[]) => boolean) | ((this: readonly T[], other: readonly T[]) => boolean) | ((this: readonly T[], other: readonly T[]) => boolean) > : ^^ ^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^ ^^^^^^ ^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^ ^^^^^^ ^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^ ^^^^^^ ^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^ ^ ->a : (string | number)[] | null[] | undefined[] | {}[] +>a : undefined[] | null[] | {}[] | (string | number)[] > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >equalsShallow : ((this: readonly T[], other: readonly T[]) => boolean) | ((this: readonly T[], other: readonly T[]) => boolean) | ((this: readonly T[], other: readonly T[]) => boolean) | ((this: readonly T[], other: readonly T[]) => boolean) > : ^^ ^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^ ^^^^^^ ^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^ ^^^^^^ ^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^ ^^^^^^ ^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^ ^ ->b : (string | number)[] | null[] | undefined[] | {}[] +>b : undefined[] | null[] | {}[] | (string | number)[] > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/baselines/reference/booleanLiteralTypes1.types b/tests/baselines/reference/booleanLiteralTypes1.types index bc640f5e0c44b..99c240c32e075 100644 --- a/tests/baselines/reference/booleanLiteralTypes1.types +++ b/tests/baselines/reference/booleanLiteralTypes1.types @@ -264,7 +264,7 @@ function assertNever(x: never): never { } function f10(x: true | false) { ->f10 : (x: true | false) => "true" | "false" +>f10 : (x: true | false) => "false" | "true" > : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ >x : boolean > : ^^^^^^^ @@ -292,7 +292,7 @@ function f10(x: true | false) { } function f11(x: true | false) { ->f11 : (x: true | false) => "true" | "false" +>f11 : (x: true | false) => "false" | "true" > : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ >x : boolean > : ^^^^^^^ diff --git a/tests/baselines/reference/booleanLiteralTypes2.types b/tests/baselines/reference/booleanLiteralTypes2.types index 484597c1ebeda..0844693f9e690 100644 --- a/tests/baselines/reference/booleanLiteralTypes2.types +++ b/tests/baselines/reference/booleanLiteralTypes2.types @@ -264,7 +264,7 @@ function assertNever(x: never): never { } function f10(x: true | false) { ->f10 : (x: true | false) => "true" | "false" +>f10 : (x: true | false) => "false" | "true" > : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ >x : boolean > : ^^^^^^^ @@ -292,7 +292,7 @@ function f10(x: true | false) { } function f11(x: true | false) { ->f11 : (x: true | false) => "true" | "false" +>f11 : (x: true | false) => "false" | "true" > : ^ ^^ ^^^^^^^^^^^^^^^^^^^^^ >x : boolean > : ^^^^^^^ diff --git a/tests/baselines/reference/builtinIterator.errors.txt b/tests/baselines/reference/builtinIterator.errors.txt index c4fc043ee366e..4a3a7eb45e00d 100644 --- a/tests/baselines/reference/builtinIterator.errors.txt +++ b/tests/baselines/reference/builtinIterator.errors.txt @@ -20,7 +20,7 @@ builtinIterator.ts(60,3): error TS2416: Property 'next' in type 'BadIterator3' i Type '{ done: boolean; value: number; }' is not assignable to type 'IteratorYieldResult'. Types of property 'done' are incompatible. Type 'boolean' is not assignable to type 'false'. -builtinIterator.ts(70,29): error TS2345: Argument of type 'Generator' is not assignable to parameter of type 'Iterator | Iterable'. +builtinIterator.ts(70,29): error TS2345: Argument of type 'Generator' is not assignable to parameter of type 'Iterable | Iterator'. Type 'Generator' is not assignable to type 'Iterator'. Types of property 'next' are incompatible. Type '(...[value]: [] | [boolean]) => IteratorResult' is not assignable to type '(...[value]: [] | [undefined]) => IteratorResult'. @@ -29,7 +29,7 @@ builtinIterator.ts(70,29): error TS2345: Argument of type 'Generator' is not assignable to type 'Iterator | Iterable'. +builtinIterator.ts(73,35): error TS2322: Type 'Generator' is not assignable to type 'Iterable | Iterator'. Type 'Generator' is not assignable to type 'Iterator'. Types of property 'next' are incompatible. Type '(...[value]: [] | [boolean]) => IteratorResult' is not assignable to type '(...[value]: [] | [undefined]) => IteratorResult'. @@ -139,7 +139,7 @@ builtinIterator.ts(73,35): error TS2322: Type 'Generator; const iter1 = Iterator.from(g1); ~~ -!!! error TS2345: Argument of type 'Generator' is not assignable to parameter of type 'Iterator | Iterable'. +!!! error TS2345: Argument of type 'Generator' is not assignable to parameter of type 'Iterable | Iterator'. !!! error TS2345: Type 'Generator' is not assignable to type 'Iterator'. !!! error TS2345: Types of property 'next' are incompatible. !!! error TS2345: Type '(...[value]: [] | [boolean]) => IteratorResult' is not assignable to type '(...[value]: [] | [undefined]) => IteratorResult'. @@ -152,7 +152,7 @@ builtinIterator.ts(73,35): error TS2322: Type 'Generator; const iter3 = iter2.flatMap(() => g1); ~~ -!!! error TS2322: Type 'Generator' is not assignable to type 'Iterator | Iterable'. +!!! error TS2322: Type 'Generator' is not assignable to type 'Iterable | Iterator'. !!! error TS2322: Type 'Generator' is not assignable to type 'Iterator'. !!! error TS2322: Types of property 'next' are incompatible. !!! error TS2322: Type '(...[value]: [] | [boolean]) => IteratorResult' is not assignable to type '(...[value]: [] | [undefined]) => IteratorResult'. diff --git a/tests/baselines/reference/builtinIterator.types b/tests/baselines/reference/builtinIterator.types index 75d934cddae8c..ce8f70bc8040f 100644 --- a/tests/baselines/reference/builtinIterator.types +++ b/tests/baselines/reference/builtinIterator.types @@ -146,9 +146,9 @@ function* gen() { } const mappedGen = gen().map(x => x === 0 ? "zero" : "other"); ->mappedGen : IteratorObject<"zero" | "other", undefined, unknown> +>mappedGen : IteratorObject<"other" | "zero", undefined, unknown> > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->gen().map(x => x === 0 ? "zero" : "other") : IteratorObject<"zero" | "other", undefined, unknown> +>gen().map(x => x === 0 ? "zero" : "other") : IteratorObject<"other" | "zero", undefined, unknown> > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >gen().map : (callbackfn: (value: number, index: number) => U) => IteratorObject > : ^ ^^ ^^^ ^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -158,11 +158,11 @@ const mappedGen = gen().map(x => x === 0 ? "zero" : "other"); > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >map : (callbackfn: (value: number, index: number) => U) => IteratorObject > : ^ ^^ ^^^ ^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->x => x === 0 ? "zero" : "other" : (x: number) => "zero" | "other" +>x => x === 0 ? "zero" : "other" : (x: number) => "other" | "zero" > : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : number > : ^^^^^^ ->x === 0 ? "zero" : "other" : "zero" | "other" +>x === 0 ? "zero" : "other" : "other" | "zero" > : ^^^^^^^^^^^^^^^^ >x === 0 : boolean > : ^^^^^^^ @@ -176,9 +176,9 @@ const mappedGen = gen().map(x => x === 0 ? "zero" : "other"); > : ^^^^^^^ const mappedValues = [0, 1, 2].values().map(x => x === 0 ? "zero" : "other"); ->mappedValues : IteratorObject<"zero" | "other", undefined, unknown> +>mappedValues : IteratorObject<"other" | "zero", undefined, unknown> > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->[0, 1, 2].values().map(x => x === 0 ? "zero" : "other") : IteratorObject<"zero" | "other", undefined, unknown> +>[0, 1, 2].values().map(x => x === 0 ? "zero" : "other") : IteratorObject<"other" | "zero", undefined, unknown> > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >[0, 1, 2].values().map : (callbackfn: (value: number, index: number) => U) => IteratorObject > : ^ ^^ ^^^ ^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -198,11 +198,11 @@ const mappedValues = [0, 1, 2].values().map(x => x === 0 ? "zero" : "other"); > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ >map : (callbackfn: (value: number, index: number) => U) => IteratorObject > : ^ ^^ ^^^ ^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->x => x === 0 ? "zero" : "other" : (x: number) => "zero" | "other" +>x => x === 0 ? "zero" : "other" : (x: number) => "other" | "zero" > : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : number > : ^^^^^^ ->x === 0 ? "zero" : "other" : "zero" | "other" +>x === 0 ? "zero" : "other" : "other" | "zero" > : ^^^^^^^^^^^^^^^^ >x === 0 : boolean > : ^^^^^^^ @@ -415,11 +415,11 @@ const iter3 = iter2.flatMap(() => g1); > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >iter2.flatMap(() => g1) : IteratorObject > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->iter2.flatMap : (callback: (value: string, index: number) => Iterator | Iterable) => IteratorObject +>iter2.flatMap : (callback: (value: string, index: number) => Iterable | Iterator) => IteratorObject > : ^ ^^ ^^^ ^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >iter2 : IteratorObject > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->flatMap : (callback: (value: string, index: number) => Iterator | Iterable) => IteratorObject +>flatMap : (callback: (value: string, index: number) => Iterable | Iterator) => IteratorObject > : ^ ^^ ^^^ ^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >() => g1 : () => Generator > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types index 724f995738871..dabd139fc9f62 100644 --- a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types +++ b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types @@ -143,21 +143,21 @@ var r6 = foo6(1); > : ^ function foo7(x) { ->foo7 : (x: any) => "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>foo7 : (x: any) => "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : any return typeof x; ->typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : any } var r7 = foo7(1); ->r7 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>r7 : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->foo7(1) : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>foo7(1) : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->foo7 : (x: any) => "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>foo7 : (x: any) => "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >1 : 1 > : ^ diff --git a/tests/baselines/reference/callWithMissingVoid.types b/tests/baselines/reference/callWithMissingVoid.types index a506760c192a2..0896a1d51dd80 100644 --- a/tests/baselines/reference/callWithMissingVoid.types +++ b/tests/baselines/reference/callWithMissingVoid.types @@ -37,29 +37,29 @@ x.f() // no error because f expects void > : ^ ^^^^^^^^^^^^^^^^^^^^^^^ declare const xUnion: X; ->xUnion : X +>xUnion : X > : ^^^^^^^^^^^^^^^^ xUnion.f(42) // no error because f accepts number ->xUnion.f(42) : { a: number | void; } +>xUnion.f(42) : { a: void | number; } > : ^^^^^^^^^^^^^^^^^^^^^ ->xUnion.f : (t: number | void) => { a: number | void; } +>xUnion.f : (t: void | number) => { a: void | number; } > : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->xUnion : X +>xUnion : X > : ^^^^^^^^^^^^^^^^ ->f : (t: number | void) => { a: number | void; } +>f : (t: void | number) => { a: void | number; } > : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >42 : 42 > : ^^ xUnion.f() // no error because f accepts void ->xUnion.f() : { a: number | void; } +>xUnion.f() : { a: void | number; } > : ^^^^^^^^^^^^^^^^^^^^^ ->xUnion.f : (t: number | void) => { a: number | void; } +>xUnion.f : (t: void | number) => { a: void | number; } > : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->xUnion : X +>xUnion : X > : ^^^^^^^^^^^^^^^^ ->f : (t: number | void) => { a: number | void; } +>f : (t: void | number) => { a: void | number; } > : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ declare const xAny: X; @@ -137,17 +137,17 @@ new MyPromise(resolve => resolve()); // no error > : ^ ^^^^^^^^^^^ new MyPromise(resolve => resolve()); // no error ->new MyPromise(resolve => resolve()) : MyPromise +>new MyPromise(resolve => resolve()) : MyPromise > : ^^^^^^^^^^^^^^^^^^^^^^^^ >MyPromise : typeof MyPromise > : ^^^^^^^^^^^^^^^^ ->resolve => resolve() : (resolve: (value: number | void) => void) => void +>resolve => resolve() : (resolve: (value: void | number) => void) => void > : ^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^ ->resolve : (value: number | void) => void +>resolve : (value: void | number) => void > : ^ ^^^^^^^^^^^^^^^^^^^^ >resolve() : void > : ^^^^ ->resolve : (value: number | void) => void +>resolve : (value: void | number) => void > : ^ ^^^^^^^^^^^^^^^^^^^^ new MyPromise(resolve => resolve()); // error, `any` arguments cannot be omitted @@ -304,11 +304,11 @@ b(4); // not ok function c(x: number | void, y: void, z: void | string | number): void { >c : (x: number | void, y: void, z: void | string | number) => void > : ^ ^^ ^^ ^^ ^^ ^^ ^^^^^ ->x : number | void +>x : void | number > : ^^^^^^^^^^^^^ >y : void > : ^^^^ ->z : string | number | void +>z : void | string | number > : ^^^^^^^^^^^^^^^^^^^^^^ } @@ -469,9 +469,9 @@ call((x: number | void, y: number | void) => 42) // ok > : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ ^^ ^^^^^ >(x: number | void, y: number | void) => 42 : (x: number | void, y: number | void) => number > : ^ ^^ ^^ ^^ ^^^^^^^^^^^ ->x : number | void +>x : void | number > : ^^^^^^^^^^^^^ ->y : number | void +>y : void | number > : ^^^^^^^^^^^^^ >42 : 42 > : ^^ @@ -483,9 +483,9 @@ call((x: number | void, y: number | void) => 42, 4) // ok > : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ ^^ ^^^^^ >(x: number | void, y: number | void) => 42 : (x: number | void, y: number | void) => number > : ^ ^^ ^^ ^^ ^^^^^^^^^^^ ->x : number | void +>x : void | number > : ^^^^^^^^^^^^^ ->y : number | void +>y : void | number > : ^^^^^^^^^^^^^ >42 : 42 > : ^^ @@ -499,9 +499,9 @@ call((x: number | void, y: number | void) => 42, 4, 2) // ok > : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ ^^ ^^^^^ >(x: number | void, y: number | void) => 42 : (x: number | void, y: number | void) => number > : ^ ^^ ^^ ^^ ^^^^^^^^^^^ ->x : number | void +>x : void | number > : ^^^^^^^^^^^^^ ->y : number | void +>y : void | number > : ^^^^^^^^^^^^^ >42 : 42 > : ^^ diff --git a/tests/baselines/reference/callWithSpread4.types b/tests/baselines/reference/callWithSpread4.types index 52a3a995a8d20..fb0661d59858b 100644 --- a/tests/baselines/reference/callWithSpread4.types +++ b/tests/baselines/reference/callWithSpread4.types @@ -38,15 +38,15 @@ declare const pli: { > : ^ (streams: ReadonlyArray): Promise; ->streams : readonly (R | W | RW)[] +>streams : readonly (R | RW | W)[] > : ^^^^^^^^^^^^^^^^^^^^^^^ (s1: R, s2: RW | W, ...streams: Array): Promise; >s1 : R > : ^ ->s2 : W | RW +>s2 : RW | W > : ^^^^^^ ->streams : (W | RW)[] +>streams : (RW | W)[] > : ^^^^^^^^^^ } diff --git a/tests/baselines/reference/callsOnComplexSignatures.types b/tests/baselines/reference/callsOnComplexSignatures.types index a9a9805eb5554..f388b127be5ec 100644 --- a/tests/baselines/reference/callsOnComplexSignatures.types +++ b/tests/baselines/reference/callsOnComplexSignatures.types @@ -18,7 +18,7 @@ function test1() { > : ^^^^^^^^^^ type stringType1 = "foo" | "bar"; ->stringType1 : "foo" | "bar" +>stringType1 : "bar" | "foo" > : ^^^^^^^^^^^^^ type stringType2 = "baz" | "bar"; @@ -27,9 +27,9 @@ function test1() { interface Temp1 { getValue(name: stringType1): number; ->getValue : (name: "foo" | "bar") => number +>getValue : (name: "bar" | "foo") => number > : ^ ^^^^^^^^^^^^^^^^^^^^ ->name : "foo" | "bar" +>name : "bar" | "foo" > : ^^^^^^^^^^^^^ } @@ -52,11 +52,11 @@ function test1() { > : ^^^^^^^^^^^^^^^ >t.getValue("bar") : string | number > : ^^^^^^^^^^^^^^^ ->t.getValue : ((name: "foo" | "bar") => number) | ((name: "bar" | "baz") => string) +>t.getValue : ((name: "bar" | "foo") => number) | ((name: "bar" | "baz") => string) > : ^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^ >t : Temp1 | Temp2 > : ^^^^^^^^^^^^^ ->getValue : ((name: "foo" | "bar") => number) | ((name: "bar" | "baz") => string) +>getValue : ((name: "bar" | "foo") => number) | ((name: "bar" | "baz") => string) > : ^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^ >"bar" : "bar" > : ^^^^^ @@ -122,7 +122,7 @@ function test2() { > : ^ ^^ ^^^^^^^^^^^ >(type: "foo" | "bar") => messages[type]({ a: "A", b: 0 }) : (type: "foo" | "bar") => string > : ^ ^^ ^^^^^^^^^^^ ->type : "foo" | "bar" +>type : "bar" | "foo" > : ^^^^^^^^^^^^^ messages[type]({ a: "A", b: 0 }); @@ -132,7 +132,7 @@ function test2() { > : ^^ ^^ ^^^^^ ^^^^^^ ^^ ^^^^^ ^ >messages : Messages > : ^^^^^^^^ ->type : "foo" | "bar" +>type : "bar" | "foo" > : ^^^^^^^^^^^^^ >{ a: "A", b: 0 } : { a: string; b: number; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/baselines/reference/castExpressionParentheses.types b/tests/baselines/reference/castExpressionParentheses.types index 71e34b3dbbd5c..6abba3993d671 100644 --- a/tests/baselines/reference/castExpressionParentheses.types +++ b/tests/baselines/reference/castExpressionParentheses.types @@ -230,7 +230,7 @@ declare var A; >(typeof A) : any > : ^^^ >typeof A : any ->typeof A : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof A : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >A : any >x : any diff --git a/tests/baselines/reference/castOfAwait.types b/tests/baselines/reference/castOfAwait.types index 0d7ac0c3956d8..777563ad043e0 100644 --- a/tests/baselines/reference/castOfAwait.types +++ b/tests/baselines/reference/castOfAwait.types @@ -14,7 +14,7 @@ async function f() { > : ^ typeof await 0; ->typeof await 0 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof await 0 : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >await 0 : 0 > : ^ @@ -36,7 +36,7 @@ async function f() { > : ^^^^^^^^^ > typeof void await 0 : string > : ^^^^^^ ->typeof void await 0 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof void await 0 : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > void await 0 : number > : ^^^^^^ diff --git a/tests/baselines/reference/checkJsdocReturnTag2.types b/tests/baselines/reference/checkJsdocReturnTag2.types index eb45cf3aad71b..e821b70179113 100644 --- a/tests/baselines/reference/checkJsdocReturnTag2.types +++ b/tests/baselines/reference/checkJsdocReturnTag2.types @@ -22,7 +22,7 @@ function f1() { > : ^^^^^^ return 5 || true; ->5 || true : true | 5 +>5 || true : 5 | true > : ^^^^^^^^ >5 : 5 > : ^ diff --git a/tests/baselines/reference/checkJsdocTypeTag5.types b/tests/baselines/reference/checkJsdocTypeTag5.types index e7500bc7c59a0..712be2605e9be 100644 --- a/tests/baselines/reference/checkJsdocTypeTag5.types +++ b/tests/baselines/reference/checkJsdocTypeTag5.types @@ -70,7 +70,7 @@ var k = function (x) { return x } function blargle(s) { >blargle : (x: "hi" | "bye") => 0 | 1 | 2 > : ^ ^^ ^^^^^ ->s : "hi" | "bye" +>s : "bye" | "hi" > : ^^^^^^^^^^^^ return 0; @@ -103,7 +103,7 @@ function monaLisa(sb) { > : ^^^^^ >typeof sb === 'string' : boolean > : ^^^^^^^ ->typeof sb : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof sb : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >sb : any > : ^^^ diff --git a/tests/baselines/reference/checkJsxChildrenProperty14.types b/tests/baselines/reference/checkJsxChildrenProperty14.types index 462991d4777c3..6ecdf6321e899 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty14.types +++ b/tests/baselines/reference/checkJsxChildrenProperty14.types @@ -15,7 +15,7 @@ interface Prop { > : ^^^^^^ children: JSX.Element | JSX.Element[]; ->children : JSX.Element | JSX.Element[] +>children : JSX.Element[] | JSX.Element > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ >JSX : any > : ^^^ diff --git a/tests/baselines/reference/checkJsxChildrenProperty6.types b/tests/baselines/reference/checkJsxChildrenProperty6.types index ce5c43d4bdc95..53cd3790a9bf8 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty6.types +++ b/tests/baselines/reference/checkJsxChildrenProperty6.types @@ -15,7 +15,7 @@ interface Prop { > : ^^^^^^ children: JSX.Element | JSX.Element[]; ->children : JSX.Element | JSX.Element[] +>children : JSX.Element[] | JSX.Element > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ >JSX : any > : ^^^ diff --git a/tests/baselines/reference/checkJsxChildrenProperty7.errors.txt b/tests/baselines/reference/checkJsxChildrenProperty7.errors.txt index c593701198647..f7cb8500cbbea 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty7.errors.txt +++ b/tests/baselines/reference/checkJsxChildrenProperty7.errors.txt @@ -1,6 +1,6 @@ -file.tsx(24,40): error TS2747: 'Comp' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of 'children' is 'Element | Element[]'. -file.tsx(26,22): error TS2747: 'Comp' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of 'children' is 'Element | Element[]'. -file.tsx(27,30): error TS2747: 'Comp' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of 'children' is 'Element | Element[]'. +file.tsx(24,40): error TS2747: 'Comp' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of 'children' is 'Element[] | Element'. +file.tsx(26,22): error TS2747: 'Comp' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of 'children' is 'Element[] | Element'. +file.tsx(27,30): error TS2747: 'Comp' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of 'children' is 'Element[] | Element'. ==== file.tsx (3 errors) ==== @@ -29,12 +29,12 @@ file.tsx(27,30): error TS2747: 'Comp' components don't accept text as child elem // Error: whitespaces matters let k1 =