diff --git a/internal/checker/types.go b/internal/checker/types.go index ae842ea0cd..2e5ea1f81d 100644 --- a/internal/checker/types.go +++ b/internal/checker/types.go @@ -427,18 +427,18 @@ const ( TypeFlagsUniqueESSymbol TypeFlags = 1 << 14 // unique symbol TypeFlagsEnumLiteral TypeFlags = 1 << 15 // Always combined with StringLiteral, NumberLiteral, or Union TypeFlagsEnum TypeFlags = 1 << 16 // Numeric computed enum member value (must be right after EnumLiteral, see getSortOrderFlags) - TypeFlagsNever TypeFlags = 1 << 17 // Never type - TypeFlagsTypeParameter TypeFlags = 1 << 18 // Type parameter - TypeFlagsObject TypeFlags = 1 << 19 // Object type - TypeFlagsUnion TypeFlags = 1 << 20 // Union (T | U) - TypeFlagsIntersection TypeFlags = 1 << 21 // Intersection (T & U) - TypeFlagsIndex TypeFlags = 1 << 22 // keyof T - TypeFlagsIndexedAccess TypeFlags = 1 << 23 // T[K] - TypeFlagsConditional TypeFlags = 1 << 24 // T extends U ? X : Y - TypeFlagsSubstitution TypeFlags = 1 << 25 // Type parameter substitution - TypeFlagsNonPrimitive TypeFlags = 1 << 26 // intrinsic object type - TypeFlagsTemplateLiteral TypeFlags = 1 << 27 // Template literal type - TypeFlagsStringMapping TypeFlags = 1 << 28 // Uppercase/Lowercase type + TypeFlagsNonPrimitive TypeFlags = 1 << 17 // intrinsic object type + TypeFlagsNever TypeFlags = 1 << 18 // Never type + TypeFlagsTypeParameter TypeFlags = 1 << 19 // Type parameter + TypeFlagsObject TypeFlags = 1 << 20 // Object type + TypeFlagsIndex TypeFlags = 1 << 21 // keyof T + TypeFlagsIndexedAccess TypeFlags = 1 << 22 // T[K] + TypeFlagsConditional TypeFlags = 1 << 23 // T extends U ? X : Y + TypeFlagsSubstitution TypeFlags = 1 << 24 // Type parameter substitution + TypeFlagsTemplateLiteral TypeFlags = 1 << 25 // Template literal type + TypeFlagsStringMapping TypeFlags = 1 << 26 // Uppercase/Lowercase type + TypeFlagsUnion TypeFlags = 1 << 27 // Union (T | U) + TypeFlagsIntersection TypeFlags = 1 << 28 // Intersection (T & U) TypeFlagsReserved1 TypeFlags = 1 << 29 // Used by union/intersection type construction TypeFlagsReserved2 TypeFlags = 1 << 30 // Used by union/intersection type construction TypeFlagsReserved3 TypeFlags = 1 << 31 diff --git a/testdata/baselines/reference/compiler/objectSubtypeReduction.symbols b/testdata/baselines/reference/compiler/objectSubtypeReduction.symbols new file mode 100644 index 0000000000..89728315e0 --- /dev/null +++ b/testdata/baselines/reference/compiler/objectSubtypeReduction.symbols @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/objectSubtypeReduction.ts] //// + +=== objectSubtypeReduction.ts === +// https://github.com/microsoft/typescript-go/issues/1164 + +function foo(x?: object) { +>foo : Symbol(foo, Decl(objectSubtypeReduction.ts, 0, 0)) +>x : Symbol(x, Decl(objectSubtypeReduction.ts, 2, 13)) + + return Object.entries(x || {}) +>Object.entries(x || {}) .sort : Symbol(sort, Decl(lib.es5.d.ts, --, --)) +>Object.entries : Symbol(entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>entries : Symbol(entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --)) +>x : Symbol(x, Decl(objectSubtypeReduction.ts, 2, 13)) + + .sort(([k1, v1], [k2, v2]) => v1.name.localeCompare(v2.name)); +>sort : Symbol(sort, Decl(lib.es5.d.ts, --, --)) +>k1 : Symbol(k1, Decl(objectSubtypeReduction.ts, 4, 16)) +>v1 : Symbol(v1, Decl(objectSubtypeReduction.ts, 4, 19)) +>k2 : Symbol(k2, Decl(objectSubtypeReduction.ts, 4, 26)) +>v2 : Symbol(v2, Decl(objectSubtypeReduction.ts, 4, 29)) +>v1 : Symbol(v1, Decl(objectSubtypeReduction.ts, 4, 19)) +>v2 : Symbol(v2, Decl(objectSubtypeReduction.ts, 4, 29)) +} + diff --git a/testdata/baselines/reference/compiler/objectSubtypeReduction.types b/testdata/baselines/reference/compiler/objectSubtypeReduction.types new file mode 100644 index 0000000000..cc84cf2e2c --- /dev/null +++ b/testdata/baselines/reference/compiler/objectSubtypeReduction.types @@ -0,0 +1,38 @@ +//// [tests/cases/compiler/objectSubtypeReduction.ts] //// + +=== objectSubtypeReduction.ts === +// https://github.com/microsoft/typescript-go/issues/1164 + +function foo(x?: object) { +>foo : (x?: object | undefined) => [string, any][] +>x : object | undefined + + return Object.entries(x || {}) +>Object.entries(x || {}) .sort(([k1, v1], [k2, v2]) => v1.name.localeCompare(v2.name)) : [string, any][] +>Object.entries(x || {}) .sort : (compareFn?: ((a: [string, any], b: [string, any]) => number) | undefined) => [string, any][] +>Object.entries(x || {}) : [string, any][] +>Object.entries : { (o: ArrayLike | { [s: string]: T; }): [string, T][]; (o: {}): [string, any][]; } +>Object : ObjectConstructor +>entries : { (o: ArrayLike | { [s: string]: T; }): [string, T][]; (o: {}): [string, any][]; } +>x || {} : object +>x : object | undefined +>{} : {} + + .sort(([k1, v1], [k2, v2]) => v1.name.localeCompare(v2.name)); +>sort : (compareFn?: ((a: [string, any], b: [string, any]) => number) | undefined) => [string, any][] +>([k1, v1], [k2, v2]) => v1.name.localeCompare(v2.name) : ([k1, v1]: [string, any], [k2, v2]: [string, any]) => any +>k1 : string +>v1 : any +>k2 : string +>v2 : any +>v1.name.localeCompare(v2.name) : any +>v1.name.localeCompare : any +>v1.name : any +>v1 : any +>name : any +>localeCompare : any +>v2.name : any +>v2 : any +>name : any +} + diff --git a/testdata/baselines/reference/submodule/compiler/circularContextualReturnType.types b/testdata/baselines/reference/submodule/compiler/circularContextualReturnType.types index c70c99f134..f922db2738 100644 --- a/testdata/baselines/reference/submodule/compiler/circularContextualReturnType.types +++ b/testdata/baselines/reference/submodule/compiler/circularContextualReturnType.types @@ -5,9 +5,9 @@ Object.freeze({ >Object.freeze({ foo() { return Object.freeze('a'); },}) : Readonly<{ foo(): string; }> ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >{ foo() { return Object.freeze('a'); },} : { foo(): string; } foo() { @@ -15,9 +15,9 @@ Object.freeze({ return Object.freeze('a'); >Object.freeze('a') : string ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >'a' : "a" }, diff --git a/testdata/baselines/reference/submodule/compiler/circularContextualReturnType.types.diff b/testdata/baselines/reference/submodule/compiler/circularContextualReturnType.types.diff index 8de456ecc6..d4cae7c8f5 100644 --- a/testdata/baselines/reference/submodule/compiler/circularContextualReturnType.types.diff +++ b/testdata/baselines/reference/submodule/compiler/circularContextualReturnType.types.diff @@ -5,10 +5,10 @@ Object.freeze({ >Object.freeze({ foo() { return Object.freeze('a'); },}) : Readonly<{ foo(): string; }> ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >{ foo() { return Object.freeze('a'); },} : { foo(): string; } foo() { @@ -17,10 +17,10 @@ return Object.freeze('a'); >Object.freeze('a') : string ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >'a' : "a" }, \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/contextualSignatureInObjectFreeze.types b/testdata/baselines/reference/submodule/compiler/contextualSignatureInObjectFreeze.types index 65ad4971c1..85af5f3c3d 100644 --- a/testdata/baselines/reference/submodule/compiler/contextualSignatureInObjectFreeze.types +++ b/testdata/baselines/reference/submodule/compiler/contextualSignatureInObjectFreeze.types @@ -5,9 +5,9 @@ Object.freeze({ >Object.freeze({ f: function () { }}) : Readonly<{ f: () => void; }> ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >{ f: function () { }} : { f: () => void; } f: function () { } diff --git a/testdata/baselines/reference/submodule/compiler/contextualSignatureInObjectFreeze.types.diff b/testdata/baselines/reference/submodule/compiler/contextualSignatureInObjectFreeze.types.diff index a049c44b4d..40101981ad 100644 --- a/testdata/baselines/reference/submodule/compiler/contextualSignatureInObjectFreeze.types.diff +++ b/testdata/baselines/reference/submodule/compiler/contextualSignatureInObjectFreeze.types.diff @@ -5,10 +5,10 @@ Object.freeze({ >Object.freeze({ f: function () { }}) : Readonly<{ f: () => void; }> ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >{ f: function () { }} : { f: () => void; } f: function () { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/correlatedUnions.types b/testdata/baselines/reference/submodule/compiler/correlatedUnions.types index 41a398fd7f..ba53ae38d7 100644 --- a/testdata/baselines/reference/submodule/compiler/correlatedUnions.types +++ b/testdata/baselines/reference/submodule/compiler/correlatedUnions.types @@ -860,15 +860,15 @@ function getConfigOrDefault( >key : T const assertedCheck = userValue ? userValue! : defaultValue; ->assertedCheck : NonNullable[T]> ->userValue ? userValue! : defaultValue : NonNullable[T]> +>assertedCheck : Config[T] +>userValue ? userValue! : defaultValue : Config[T] >userValue : Partial[T] >userValue! : NonNullable[T]> >userValue : NonNullable[T]> >defaultValue : Config[T] return assertedCheck; ->assertedCheck : NonNullable[T]> +>assertedCheck : Config[T] } // repro from #47523 diff --git a/testdata/baselines/reference/submodule/compiler/correlatedUnions.types.diff b/testdata/baselines/reference/submodule/compiler/correlatedUnions.types.diff index 1e94053bb7..23d299c30c 100644 --- a/testdata/baselines/reference/submodule/compiler/correlatedUnions.types.diff +++ b/testdata/baselines/reference/submodule/compiler/correlatedUnions.types.diff @@ -141,4 +141,23 @@ +>< K extends KeyOfOriginal, N extends NestedKeyOfOriginalFor>( original: Original, mappedFromOriginal: MappedFromOriginal, key: K, nestedKey: N): [Original[K][N], MappedFromOriginal[K][N]] => { return [original[key][nestedKey], mappedFromOriginal[key][nestedKey]];} : (original: Original, mappedFromOriginal: SameKeys, key: K, nestedKey: N) => [Original[K][N], SameKeys[K][N]] K extends KeyOfOriginal, - N extends NestedKeyOfOriginalFor \ No newline at end of file + N extends NestedKeyOfOriginalFor +@@= skipped -63, +63 lines =@@ + >key : T + + const assertedCheck = userValue ? userValue! : defaultValue; +->assertedCheck : NonNullable[T]> +->userValue ? userValue! : defaultValue : NonNullable[T]> ++>assertedCheck : Config[T] ++>userValue ? userValue! : defaultValue : Config[T] + >userValue : Partial[T] + >userValue! : NonNullable[T]> + >userValue : NonNullable[T]> + >defaultValue : Config[T] + + return assertedCheck; +->assertedCheck : NonNullable[T]> ++>assertedCheck : Config[T] + } + + // repro from #47523 \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsEnumTagOnObjectFrozen.types b/testdata/baselines/reference/submodule/compiler/jsEnumTagOnObjectFrozen.types index 935ccf7ad4..5d912b169c 100644 --- a/testdata/baselines/reference/submodule/compiler/jsEnumTagOnObjectFrozen.types +++ b/testdata/baselines/reference/submodule/compiler/jsEnumTagOnObjectFrozen.types @@ -51,9 +51,9 @@ cbThing(type => { const Thing = Object.freeze({ >Thing : Readonly<{ a: "thing"; b: "chill"; }> >Object.freeze({ a: "thing", b: "chill"}) : Readonly<{ a: "thing"; b: "chill"; }> ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >{ a: "thing", b: "chill"} : { a: "thing"; b: "chill"; } a: "thing", diff --git a/testdata/baselines/reference/submodule/compiler/objectFreeze.types b/testdata/baselines/reference/submodule/compiler/objectFreeze.types index 959c5d0839..c7f5f48145 100644 --- a/testdata/baselines/reference/submodule/compiler/objectFreeze.types +++ b/testdata/baselines/reference/submodule/compiler/objectFreeze.types @@ -4,9 +4,9 @@ const f = Object.freeze(function foo(a: number, b: string) { return false; }); >f : (a: number, b: string) => false >Object.freeze(function foo(a: number, b: string) { return false; }) : (a: number, b: string) => false ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >function foo(a: number, b: string) { return false; } : (a: number, b: string) => false >foo : (a: number, b: string) => false >a : number @@ -28,9 +28,9 @@ class C { constructor(a: number) { } } const c = Object.freeze(C); >c : typeof C >Object.freeze(C) : typeof C ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >C : typeof C new c(1); @@ -41,9 +41,9 @@ new c(1); const a = Object.freeze([1, 2, 3]); >a : readonly number[] >Object.freeze([1, 2, 3]) : readonly number[] ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >[1, 2, 3] : number[] >1 : 1 >2 : 2 @@ -64,9 +64,9 @@ a[0] = a[2].toString(); const o = Object.freeze({ a: 1, b: "string", c: true }); >o : Readonly<{ a: 1; b: "string"; c: true; }> >Object.freeze({ a: 1, b: "string", c: true }) : Readonly<{ a: 1; b: "string"; c: true; }> ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >{ a: 1, b: "string", c: true } : { a: 1; b: "string"; c: true; } >a : 1 >1 : 1 diff --git a/testdata/baselines/reference/submodule/compiler/objectFreeze.types.diff b/testdata/baselines/reference/submodule/compiler/objectFreeze.types.diff index beb23a3898..ed85e596b2 100644 --- a/testdata/baselines/reference/submodule/compiler/objectFreeze.types.diff +++ b/testdata/baselines/reference/submodule/compiler/objectFreeze.types.diff @@ -5,10 +5,10 @@ >f : (a: number, b: string) => false >Object.freeze(function foo(a: number, b: string) { return false; }) : (a: number, b: string) => false ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >function foo(a: number, b: string) { return false; } : (a: number, b: string) => false >foo : (a: number, b: string) => false >a : number @@ -17,10 +17,10 @@ >c : typeof C >Object.freeze(C) : typeof C ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >C : typeof C new c(1); @@ -29,10 +29,10 @@ >a : readonly number[] >Object.freeze([1, 2, 3]) : readonly number[] ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >[1, 2, 3] : number[] >1 : 1 >2 : 2 @@ -41,10 +41,10 @@ >o : Readonly<{ a: 1; b: "string"; c: true; }> >Object.freeze({ a: 1, b: "string", c: true }) : Readonly<{ a: 1; b: "string"; c: true; }> ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >{ a: 1, b: "string", c: true } : { a: 1; b: "string"; c: true; } >a : 1 >1 : 1 \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/objectFreezeLiteralsDontWiden.types b/testdata/baselines/reference/submodule/compiler/objectFreezeLiteralsDontWiden.types index 514742ad57..bb19eabaf2 100644 --- a/testdata/baselines/reference/submodule/compiler/objectFreezeLiteralsDontWiden.types +++ b/testdata/baselines/reference/submodule/compiler/objectFreezeLiteralsDontWiden.types @@ -4,9 +4,9 @@ const PUPPETEER_REVISIONS = Object.freeze({ >PUPPETEER_REVISIONS : Readonly<{ chromium: "1011831"; firefox: "latest"; }> >Object.freeze({ chromium: '1011831', firefox: 'latest',}) : Readonly<{ chromium: "1011831"; firefox: "latest"; }> ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >{ chromium: '1011831', firefox: 'latest',} : { chromium: "1011831"; firefox: "latest"; } chromium: '1011831', diff --git a/testdata/baselines/reference/submodule/compiler/objectFreezeLiteralsDontWiden.types.diff b/testdata/baselines/reference/submodule/compiler/objectFreezeLiteralsDontWiden.types.diff index 2ff83939c6..9abf3495af 100644 --- a/testdata/baselines/reference/submodule/compiler/objectFreezeLiteralsDontWiden.types.diff +++ b/testdata/baselines/reference/submodule/compiler/objectFreezeLiteralsDontWiden.types.diff @@ -5,10 +5,10 @@ >PUPPETEER_REVISIONS : Readonly<{ chromium: "1011831"; firefox: "latest"; }> >Object.freeze({ chromium: '1011831', firefox: 'latest',}) : Readonly<{ chromium: "1011831"; firefox: "latest"; }> ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >{ chromium: '1011831', firefox: 'latest',} : { chromium: "1011831"; firefox: "latest"; } chromium: '1011831', \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/objectFromEntries.types b/testdata/baselines/reference/submodule/compiler/objectFromEntries.types index 6ba3724e1e..d94b14975a 100644 --- a/testdata/baselines/reference/submodule/compiler/objectFromEntries.types +++ b/testdata/baselines/reference/submodule/compiler/objectFromEntries.types @@ -45,9 +45,9 @@ const o3 = Object.fromEntries(new Map([[Symbol("key"), "value"]])); const frozenArray = Object.freeze([['a', 1], ['b', 2], ['c', 3]]); >frozenArray : readonly (string | number)[][] >Object.freeze([['a', 1], ['b', 2], ['c', 3]]) : readonly (string | number)[][] ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >[['a', 1], ['b', 2], ['c', 3]] : (string | number)[][] >['a', 1] : (string | number)[] >'a' : "a" @@ -70,9 +70,9 @@ const o4 = Object.fromEntries(frozenArray); const frozenArray2: readonly [string, number][] = Object.freeze([['a', 1], ['b', 2], ['c', 3]]); >frozenArray2 : readonly [string, number][] >Object.freeze([['a', 1], ['b', 2], ['c', 3]]) : readonly [string, number][] ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >[['a', 1], ['b', 2], ['c', 3]] : [string, number][] >['a', 1] : [string, number] >'a' : "a" diff --git a/testdata/baselines/reference/submodule/compiler/objectFromEntries.types.diff b/testdata/baselines/reference/submodule/compiler/objectFromEntries.types.diff index 082c28d2c7..7a8698fd9d 100644 --- a/testdata/baselines/reference/submodule/compiler/objectFromEntries.types.diff +++ b/testdata/baselines/reference/submodule/compiler/objectFromEntries.types.diff @@ -14,10 +14,10 @@ >frozenArray : readonly (string | number)[][] >Object.freeze([['a', 1], ['b', 2], ['c', 3]]) : readonly (string | number)[][] ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >[['a', 1], ['b', 2], ['c', 3]] : (string | number)[][] >['a', 1] : (string | number)[] >'a' : "a" @@ -26,10 +26,10 @@ >frozenArray2 : readonly [string, number][] >Object.freeze([['a', 1], ['b', 2], ['c', 3]]) : readonly [string, number][] ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >[['a', 1], ['b', 2], ['c', 3]] : [string, number][] >['a', 1] : [string, number] >'a' : "a" \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/objectLiteralExcessProperties.types b/testdata/baselines/reference/submodule/compiler/objectLiteralExcessProperties.types index 443700cc60..a145c46afd 100644 --- a/testdata/baselines/reference/submodule/compiler/objectLiteralExcessProperties.types +++ b/testdata/baselines/reference/submodule/compiler/objectLiteralExcessProperties.types @@ -145,7 +145,7 @@ function test() { // No excess property checks when union includes 'object' type const obj5: object | { x: string } = { z: 'abc' } ->obj5 : { x: string; } | object +>obj5 : object | { x: string; } >x : string >{ z: 'abc' } : { z: string; } >z : string diff --git a/testdata/baselines/reference/submodule/compiler/objectLiteralExcessProperties.types.diff b/testdata/baselines/reference/submodule/compiler/objectLiteralExcessProperties.types.diff index 16cea5d93a..ebfd5a47ca 100644 --- a/testdata/baselines/reference/submodule/compiler/objectLiteralExcessProperties.types.diff +++ b/testdata/baselines/reference/submodule/compiler/objectLiteralExcessProperties.types.diff @@ -17,4 +17,13 @@ +>obj4 : { name: string; } | T & { prop: boolean; } >prop : boolean >name : string - >{ name: "test", prop: true } : { name: string; prop: boolean; } \ No newline at end of file + >{ name: "test", prop: true } : { name: string; prop: boolean; } +@@= skipped -11, +11 lines =@@ + + // No excess property checks when union includes 'object' type + const obj5: object | { x: string } = { z: 'abc' } +->obj5 : { x: string; } | object ++>obj5 : object | { x: string; } + >x : string + >{ z: 'abc' } : { z: string; } + >z : string \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/typeGuardConstructorClassAndNumber.types b/testdata/baselines/reference/submodule/compiler/typeGuardConstructorClassAndNumber.types index 1828cc5e86..5efc141784 100644 --- a/testdata/baselines/reference/submodule/compiler/typeGuardConstructorClassAndNumber.types +++ b/testdata/baselines/reference/submodule/compiler/typeGuardConstructorClassAndNumber.types @@ -321,13 +321,13 @@ else { // Repro from #37660 function foo(instance: Function | object) { ->foo : (instance: Function | object) => number ->instance : Function | object +>foo : (instance: object | Function) => number +>instance : object | Function if (typeof instance === 'function') { >typeof instance === 'function' : boolean >typeof instance : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" ->instance : Function | object +>instance : object | Function >'function' : "function" if (instance.prototype == null || instance.prototype.constructor == null) { diff --git a/testdata/baselines/reference/submodule/compiler/typeGuardConstructorClassAndNumber.types.diff b/testdata/baselines/reference/submodule/compiler/typeGuardConstructorClassAndNumber.types.diff new file mode 100644 index 0000000000..27fb073af6 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/typeGuardConstructorClassAndNumber.types.diff @@ -0,0 +1,19 @@ +--- old.typeGuardConstructorClassAndNumber.types ++++ new.typeGuardConstructorClassAndNumber.types +@@= skipped -320, +320 lines =@@ + // Repro from #37660 + + function foo(instance: Function | object) { +->foo : (instance: Function | object) => number +->instance : Function | object ++>foo : (instance: object | Function) => number ++>instance : object | Function + + if (typeof instance === 'function') { + >typeof instance === 'function' : boolean + >typeof instance : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" +->instance : Function | object ++>instance : object | Function + >'function' : "function" + + if (instance.prototype == null || instance.prototype.constructor == null) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/unionOfFunctionAndSignatureIsCallable.types b/testdata/baselines/reference/submodule/compiler/unionOfFunctionAndSignatureIsCallable.types index 9595619643..62766a08ce 100644 --- a/testdata/baselines/reference/submodule/compiler/unionOfFunctionAndSignatureIsCallable.types +++ b/testdata/baselines/reference/submodule/compiler/unionOfFunctionAndSignatureIsCallable.types @@ -26,15 +26,15 @@ function f1(c1: Function, c2: () => object, callable: typeof c1 | typeof c2) { } function f2(fetcherParams: object | (() => object)) { ->f2 : (fetcherParams: (() => object) | object) => void ->fetcherParams : (() => object) | object +>f2 : (fetcherParams: object | (() => object)) => void +>fetcherParams : object | (() => object) const data = typeof fetcherParams === 'function' >data : any >typeof fetcherParams === 'function' ? fetcherParams() : fetcherParams : any >typeof fetcherParams === 'function' : boolean >typeof fetcherParams : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" ->fetcherParams : (() => object) | object +>fetcherParams : object | (() => object) >'function' : "function" ? fetcherParams() diff --git a/testdata/baselines/reference/submodule/compiler/unionOfFunctionAndSignatureIsCallable.types.diff b/testdata/baselines/reference/submodule/compiler/unionOfFunctionAndSignatureIsCallable.types.diff index 9468dc9d69..a88707ecaf 100644 --- a/testdata/baselines/reference/submodule/compiler/unionOfFunctionAndSignatureIsCallable.types.diff +++ b/testdata/baselines/reference/submodule/compiler/unionOfFunctionAndSignatureIsCallable.types.diff @@ -21,9 +21,9 @@ } function f2(fetcherParams: object | (() => object)) { -->f2 : (fetcherParams: object | (() => object)) => void -+>f2 : (fetcherParams: (() => object) | object) => void - >fetcherParams : (() => object) | object + >f2 : (fetcherParams: object | (() => object)) => void +->fetcherParams : (() => object) | object ++>fetcherParams : object | (() => object) const data = typeof fetcherParams === 'function' ->data : error @@ -32,7 +32,8 @@ +>typeof fetcherParams === 'function' ? fetcherParams() : fetcherParams : any >typeof fetcherParams === 'function' : boolean >typeof fetcherParams : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" - >fetcherParams : (() => object) | object +->fetcherParams : (() => object) | object ++>fetcherParams : object | (() => object) >'function' : "function" ? fetcherParams() diff --git a/testdata/baselines/reference/submodule/compiler/vueLikeDataAndPropsInference2.types b/testdata/baselines/reference/submodule/compiler/vueLikeDataAndPropsInference2.types index 3ec1e93768..9d7f70804b 100644 --- a/testdata/baselines/reference/submodule/compiler/vueLikeDataAndPropsInference2.types +++ b/testdata/baselines/reference/submodule/compiler/vueLikeDataAndPropsInference2.types @@ -45,16 +45,16 @@ type ThisTypedOptions = ThisType & Instance> declare function test(fn: ThisTypedOptions): void; ->test : { (fn: ThisTypedOptions): void; (fn: Options<((this: Instance) => object) | object, PropsDefinition>>): void; } +>test : { (fn: ThisTypedOptions): void; (fn: Options object), PropsDefinition>>): void; } >fn : ThisTypedOptions declare function test(fn: Options): void; ->test : { (fn: ThisTypedOptions): void; (fn: Options<((this: Instance) => object) | object, PropsDefinition>>): void; } ->fn : Options<((this: Instance) => object) | object, PropsDefinition>> +>test : { (fn: ThisTypedOptions): void; (fn: Options object), PropsDefinition>>): void; } +>fn : Options object), PropsDefinition>> test({ >test({ props: { foo: '' }, data(): { bar: boolean } { return { bar: true } }, watch: { foo(newVal: string, oldVal: string): void { this.bar = false } }}) : void ->test : { (fn: ThisTypedOptions): void; (fn: Options<((this: Instance) => object) | object, PropsDefinition>>): void; } +>test : { (fn: ThisTypedOptions): void; (fn: Options object), PropsDefinition>>): void; } >{ props: { foo: '' }, data(): { bar: boolean } { return { bar: true } }, watch: { foo(newVal: string, oldVal: string): void { this.bar = false } }} : { props: { foo: string; }; data(this: Readonly<{ foo: string; }> & Instance): { bar: boolean; }; watch: { foo(newVal: string, oldVal: string): void; }; } props: { diff --git a/testdata/baselines/reference/submodule/compiler/vueLikeDataAndPropsInference2.types.diff b/testdata/baselines/reference/submodule/compiler/vueLikeDataAndPropsInference2.types.diff index b7fbfe77c3..beb4d294c7 100644 --- a/testdata/baselines/reference/submodule/compiler/vueLikeDataAndPropsInference2.types.diff +++ b/testdata/baselines/reference/submodule/compiler/vueLikeDataAndPropsInference2.types.diff @@ -5,18 +5,19 @@ declare function test(fn: ThisTypedOptions): void; ->test : { (fn: ThisTypedOptions): void; (fn: Options): void; } -+>test : { (fn: ThisTypedOptions): void; (fn: Options<((this: Instance) => object) | object, PropsDefinition>>): void; } ++>test : { (fn: ThisTypedOptions): void; (fn: Options object), PropsDefinition>>): void; } >fn : ThisTypedOptions declare function test(fn: Options): void; ->test : { (fn: ThisTypedOptions): void; (fn: Options): void; } -+>test : { (fn: ThisTypedOptions): void; (fn: Options<((this: Instance) => object) | object, PropsDefinition>>): void; } - >fn : Options<((this: Instance) => object) | object, PropsDefinition>> +->fn : Options<((this: Instance) => object) | object, PropsDefinition>> ++>test : { (fn: ThisTypedOptions): void; (fn: Options object), PropsDefinition>>): void; } ++>fn : Options object), PropsDefinition>> test({ >test({ props: { foo: '' }, data(): { bar: boolean } { return { bar: true } }, watch: { foo(newVal: string, oldVal: string): void { this.bar = false } }}) : void ->test : { (fn: ThisTypedOptions): void; (fn: Options): void; } -+>test : { (fn: ThisTypedOptions): void; (fn: Options<((this: Instance) => object) | object, PropsDefinition>>): void; } ++>test : { (fn: ThisTypedOptions): void; (fn: Options object), PropsDefinition>>): void; } >{ props: { foo: '' }, data(): { bar: boolean } { return { bar: true } }, watch: { foo(newVal: string, oldVal: string): void { this.bar = false } }} : { props: { foo: string; }; data(this: Readonly<{ foo: string; }> & Instance): { bar: boolean; }; watch: { foo(newVal: string, oldVal: string): void; }; } props: { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/conditionalTypes2.types b/testdata/baselines/reference/submodule/conformance/conditionalTypes2.types index 4d09072900..976b54e78b 100644 --- a/testdata/baselines/reference/submodule/conformance/conditionalTypes2.types +++ b/testdata/baselines/reference/submodule/conformance/conditionalTypes2.types @@ -277,8 +277,8 @@ interface B1 extends A1 { // Repro from #22899 declare function toString1(value: object | Function): string ; ->toString1 : (value: Function | object) => string ->value : Function | object +>toString1 : (value: object | Function) => string +>value : object | Function declare function toString2(value: Function): string ; >toString2 : (value: Function) => string @@ -295,7 +295,7 @@ function foo(value: T) { toString1(value); >toString1(value) : string ->toString1 : (value: Function | object) => string +>toString1 : (value: object | Function) => string >value : Extract toString2(value); diff --git a/testdata/baselines/reference/submodule/conformance/conditionalTypes2.types.diff b/testdata/baselines/reference/submodule/conformance/conditionalTypes2.types.diff index 6b5ba46c47..276c5aa2c2 100644 --- a/testdata/baselines/reference/submodule/conformance/conditionalTypes2.types.diff +++ b/testdata/baselines/reference/submodule/conformance/conditionalTypes2.types.diff @@ -9,25 +9,16 @@ >predicate : (v: T) => boolean >v : T -@@= skipped -28, +28 lines =@@ - // Repro from #22899 +@@= skipped -29, +29 lines =@@ declare function toString1(value: object | Function): string ; -->toString1 : (value: object | Function) => string -+>toString1 : (value: Function | object) => string - >value : Function | object + >toString1 : (value: object | Function) => string +->value : Function | object ++>value : object | Function declare function toString2(value: Function): string ; -@@= skipped -18, +18 lines =@@ - - toString1(value); - >toString1(value) : string -->toString1 : (value: object | Function) => string -+>toString1 : (value: Function | object) => string - >value : Extract - - toString2(value); -@@= skipped -156, +156 lines =@@ + >toString2 : (value: Function) => string +@@= skipped -173, +173 lines =@@ // Repro from #33568 declare function save(_response: IRootResponse): void; diff --git a/testdata/baselines/reference/submodule/conformance/generatorYieldContextualType.types b/testdata/baselines/reference/submodule/conformance/generatorYieldContextualType.types index cb7d7fb1c5..fb0d700541 100644 --- a/testdata/baselines/reference/submodule/conformance/generatorYieldContextualType.types +++ b/testdata/baselines/reference/submodule/conformance/generatorYieldContextualType.types @@ -192,7 +192,7 @@ type StepState> = T & { }; function canPickStepContinue( ->canPickStepContinue : >(_step: T, _state: PartialStepState, _selection: Directive | StepItemType) => _selection is StepItemType +>canPickStepContinue : >(_step: T, _state: PartialStepState, _selection: StepItemType | Directive) => _selection is StepItemType _step: T, >_step : T @@ -201,7 +201,7 @@ function canPickStepContinue( >_state : PartialStepState _selection: StepItemType | Directive ->_selection : Directive | StepItemType +>_selection : StepItemType | Directive ): _selection is StepItemType { return false; @@ -258,7 +258,7 @@ function* showStep< return canPickStepContinue(step, state, selection) >canPickStepContinue(step, state, selection) ? selection[0] : StepResult.Break : unique symbol | QuickPickItem >canPickStepContinue(step, state, selection) : boolean ->canPickStepContinue : >(_step: T, _state: PartialStepState, _selection: Directive | StepItemType) => _selection is StepItemType +>canPickStepContinue : >(_step: T, _state: PartialStepState, _selection: StepItemType | Directive) => _selection is StepItemType >step : QuickPickStep >state : State >selection : QuickPickItem[] | Directive diff --git a/testdata/baselines/reference/submodule/conformance/generatorYieldContextualType.types.diff b/testdata/baselines/reference/submodule/conformance/generatorYieldContextualType.types.diff index 024ea2474a..231e317d4c 100644 --- a/testdata/baselines/reference/submodule/conformance/generatorYieldContextualType.types.diff +++ b/testdata/baselines/reference/submodule/conformance/generatorYieldContextualType.types.diff @@ -42,11 +42,20 @@ function canPickStepContinue( ->canPickStepContinue : (_step: T, _state: PartialStepState, _selection: StepItemType | Directive) => _selection is StepItemType -+>canPickStepContinue : >(_step: T, _state: PartialStepState, _selection: Directive | StepItemType) => _selection is StepItemType ++>canPickStepContinue : >(_step: T, _state: PartialStepState, _selection: StepItemType | Directive) => _selection is StepItemType _step: T, >_step : T -@@= skipped -28, +28 lines =@@ +@@= skipped -9, +9 lines =@@ + >_state : PartialStepState + + _selection: StepItemType | Directive +->_selection : Directive | StepItemType ++>_selection : StepItemType | Directive + + ): _selection is StepItemType { + return false; +@@= skipped -19, +19 lines =@@ } function* showStep< @@ -60,7 +69,7 @@ >canPickStepContinue(step, state, selection) ? selection[0] : StepResult.Break : unique symbol | QuickPickItem >canPickStepContinue(step, state, selection) : boolean ->canPickStepContinue : (_step: T, _state: PartialStepState, _selection: StepItemType | Directive) => _selection is StepItemType -+>canPickStepContinue : >(_step: T, _state: PartialStepState, _selection: Directive | StepItemType) => _selection is StepItemType ++>canPickStepContinue : >(_step: T, _state: PartialStepState, _selection: StepItemType | Directive) => _selection is StepItemType >step : QuickPickStep >state : State >selection : QuickPickItem[] | Directive \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/inOperatorWithValidOperands.errors.txt b/testdata/baselines/reference/submodule/conformance/inOperatorWithValidOperands.errors.txt index 626bfc1a7e..0fad942f62 100644 --- a/testdata/baselines/reference/submodule/conformance/inOperatorWithValidOperands.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/inOperatorWithValidOperands.errors.txt @@ -1,7 +1,7 @@ inOperatorWithValidOperands.ts(26,20): error TS2322: Type 'T' is not assignable to type 'object'. inOperatorWithValidOperands.ts(30,20): error TS2322: Type 'T | U' is not assignable to type 'object'. Type 'T' is not assignable to type 'object'. -inOperatorWithValidOperands.ts(34,20): error TS2322: Type 'T | object' is not assignable to type 'object'. +inOperatorWithValidOperands.ts(34,20): error TS2322: Type 'object | T' is not assignable to type 'object'. Type 'T' is not assignable to type 'object'. @@ -48,7 +48,7 @@ inOperatorWithValidOperands.ts(34,20): error TS2322: Type 'T | object' is not as function unionCase2(t: T | object) { var rb5 = x in t; ~ -!!! error TS2322: Type 'T | object' is not assignable to type 'object'. +!!! error TS2322: Type 'object | T' is not assignable to type 'object'. !!! error TS2322: Type 'T' is not assignable to type 'object'. !!! related TS2208 inOperatorWithValidOperands.ts:33:21: This type parameter might need an `extends object` constraint. } diff --git a/testdata/baselines/reference/submodule/conformance/inOperatorWithValidOperands.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/inOperatorWithValidOperands.errors.txt.diff new file mode 100644 index 0000000000..db953e8336 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/inOperatorWithValidOperands.errors.txt.diff @@ -0,0 +1,20 @@ +--- old.inOperatorWithValidOperands.errors.txt ++++ new.inOperatorWithValidOperands.errors.txt +@@= skipped -0, +0 lines =@@ + inOperatorWithValidOperands.ts(26,20): error TS2322: Type 'T' is not assignable to type 'object'. + inOperatorWithValidOperands.ts(30,20): error TS2322: Type 'T | U' is not assignable to type 'object'. + Type 'T' is not assignable to type 'object'. +-inOperatorWithValidOperands.ts(34,20): error TS2322: Type 'T | object' is not assignable to type 'object'. ++inOperatorWithValidOperands.ts(34,20): error TS2322: Type 'object | T' is not assignable to type 'object'. + Type 'T' is not assignable to type 'object'. + + +@@= skipped -47, +47 lines =@@ + function unionCase2(t: T | object) { + var rb5 = x in t; + ~ +-!!! error TS2322: Type 'T | object' is not assignable to type 'object'. ++!!! error TS2322: Type 'object | T' is not assignable to type 'object'. + !!! error TS2322: Type 'T' is not assignable to type 'object'. + !!! related TS2208 inOperatorWithValidOperands.ts:33:21: This type parameter might need an `extends object` constraint. + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/inOperatorWithValidOperands.types b/testdata/baselines/reference/submodule/conformance/inOperatorWithValidOperands.types index 22673ba3df..ac09a7708f 100644 --- a/testdata/baselines/reference/submodule/conformance/inOperatorWithValidOperands.types +++ b/testdata/baselines/reference/submodule/conformance/inOperatorWithValidOperands.types @@ -100,14 +100,14 @@ function unionCase(t: T | U) { } function unionCase2(t: T | object) { ->unionCase2 : (t: T | object) => void ->t : T | object +>unionCase2 : (t: object | T) => void +>t : object | T var rb5 = x in t; >rb5 : boolean >x in t : boolean >x : any ->t : T | object +>t : object | T } interface X { x: number } diff --git a/testdata/baselines/reference/submodule/conformance/inOperatorWithValidOperands.types.diff b/testdata/baselines/reference/submodule/conformance/inOperatorWithValidOperands.types.diff new file mode 100644 index 0000000000..5fc7f20707 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/inOperatorWithValidOperands.types.diff @@ -0,0 +1,20 @@ +--- old.inOperatorWithValidOperands.types ++++ new.inOperatorWithValidOperands.types +@@= skipped -99, +99 lines =@@ + } + + function unionCase2(t: T | object) { +->unionCase2 : (t: T | object) => void +->t : T | object ++>unionCase2 : (t: object | T) => void ++>t : object | T + + var rb5 = x in t; + >rb5 : boolean + >x in t : boolean + >x : any +->t : T | object ++>t : object | T + } + + interface X { x: number } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/keyofAndIndexedAccess.types b/testdata/baselines/reference/submodule/conformance/keyofAndIndexedAccess.types index 289ba942d3..41c7726b3f 100644 --- a/testdata/baselines/reference/submodule/conformance/keyofAndIndexedAccess.types +++ b/testdata/baselines/reference/submodule/conformance/keyofAndIndexedAccess.types @@ -1876,9 +1876,9 @@ class SampleClass

{ >this : this >props : Readonly

>Object.freeze(props) : Readonly

->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >props : P } } diff --git a/testdata/baselines/reference/submodule/conformance/keyofAndIndexedAccess.types.diff b/testdata/baselines/reference/submodule/conformance/keyofAndIndexedAccess.types.diff index 3ab9357a1c..4fd830c61b 100644 --- a/testdata/baselines/reference/submodule/conformance/keyofAndIndexedAccess.types.diff +++ b/testdata/baselines/reference/submodule/conformance/keyofAndIndexedAccess.types.diff @@ -184,10 +184,10 @@ >props : Readonly

>Object.freeze(props) : Readonly

->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >props : P } } diff --git a/testdata/baselines/reference/submodule/conformance/nonPrimitiveAndTypeVariables.errors.txt b/testdata/baselines/reference/submodule/conformance/nonPrimitiveAndTypeVariables.errors.txt index c5d319776b..2929c9cd00 100644 --- a/testdata/baselines/reference/submodule/conformance/nonPrimitiveAndTypeVariables.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nonPrimitiveAndTypeVariables.errors.txt @@ -1,5 +1,5 @@ nonPrimitiveAndTypeVariables.ts(10,9): error TS2322: Type 'T' is not assignable to type 'object'. -nonPrimitiveAndTypeVariables.ts(11,9): error TS2322: Type 'T' is not assignable to type 'U | object'. +nonPrimitiveAndTypeVariables.ts(11,9): error TS2322: Type 'T' is not assignable to type 'object | U'. ==== nonPrimitiveAndTypeVariables.ts (2 errors) ==== @@ -18,7 +18,7 @@ nonPrimitiveAndTypeVariables.ts(11,9): error TS2322: Type 'T' is not assignable !!! related TS2208 nonPrimitiveAndTypeVariables.ts:9:14: This type parameter might need an `extends object` constraint. let b: U | object = x; // Error ~ -!!! error TS2322: Type 'T' is not assignable to type 'U | object'. -!!! related TS2208 nonPrimitiveAndTypeVariables.ts:9:14: This type parameter might need an `extends U | object` constraint. +!!! error TS2322: Type 'T' is not assignable to type 'object | U'. +!!! related TS2208 nonPrimitiveAndTypeVariables.ts:9:14: This type parameter might need an `extends object | U` constraint. } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nonPrimitiveAndTypeVariables.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nonPrimitiveAndTypeVariables.errors.txt.diff new file mode 100644 index 0000000000..c31a26f2e1 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nonPrimitiveAndTypeVariables.errors.txt.diff @@ -0,0 +1,19 @@ +--- old.nonPrimitiveAndTypeVariables.errors.txt ++++ new.nonPrimitiveAndTypeVariables.errors.txt +@@= skipped -0, +0 lines =@@ + nonPrimitiveAndTypeVariables.ts(10,9): error TS2322: Type 'T' is not assignable to type 'object'. +-nonPrimitiveAndTypeVariables.ts(11,9): error TS2322: Type 'T' is not assignable to type 'U | object'. ++nonPrimitiveAndTypeVariables.ts(11,9): error TS2322: Type 'T' is not assignable to type 'object | U'. + + + ==== nonPrimitiveAndTypeVariables.ts (2 errors) ==== +@@= skipped -17, +17 lines =@@ + !!! related TS2208 nonPrimitiveAndTypeVariables.ts:9:14: This type parameter might need an `extends object` constraint. + let b: U | object = x; // Error + ~ +-!!! error TS2322: Type 'T' is not assignable to type 'U | object'. +-!!! related TS2208 nonPrimitiveAndTypeVariables.ts:9:14: This type parameter might need an `extends U | object` constraint. ++!!! error TS2322: Type 'T' is not assignable to type 'object | U'. ++!!! related TS2208 nonPrimitiveAndTypeVariables.ts:9:14: This type parameter might need an `extends object | U` constraint. + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nonPrimitiveAndTypeVariables.types b/testdata/baselines/reference/submodule/conformance/nonPrimitiveAndTypeVariables.types index 11b929aa25..49259df111 100644 --- a/testdata/baselines/reference/submodule/conformance/nonPrimitiveAndTypeVariables.types +++ b/testdata/baselines/reference/submodule/conformance/nonPrimitiveAndTypeVariables.types @@ -32,7 +32,7 @@ function foo(x: T) { >x : T let b: U | object = x; // Error ->b : U | object +>b : object | U >x : T } diff --git a/testdata/baselines/reference/submodule/conformance/nonPrimitiveAndTypeVariables.types.diff b/testdata/baselines/reference/submodule/conformance/nonPrimitiveAndTypeVariables.types.diff new file mode 100644 index 0000000000..234342215b --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nonPrimitiveAndTypeVariables.types.diff @@ -0,0 +1,10 @@ +--- old.nonPrimitiveAndTypeVariables.types ++++ new.nonPrimitiveAndTypeVariables.types +@@= skipped -31, +31 lines =@@ + >x : T + + let b: U | object = x; // Error +->b : U | object ++>b : object | U + >x : T + } diff --git a/testdata/baselines/reference/submodule/conformance/spreadObjectOrFalsy.types b/testdata/baselines/reference/submodule/conformance/spreadObjectOrFalsy.types index f7a12a178a..270318d4fe 100644 --- a/testdata/baselines/reference/submodule/conformance/spreadObjectOrFalsy.types +++ b/testdata/baselines/reference/submodule/conformance/spreadObjectOrFalsy.types @@ -29,12 +29,12 @@ function f3(a: T) { } function f4(a: object | T) { ->f4 : (a: T | object) => {} ->a : T | object +>f4 : (a: object | T) => {} +>a : object | T return { ...a }; >{ ...a } : {} ->a : T | object +>a : object | T } function f5(a: S | T) { diff --git a/testdata/baselines/reference/submodule/conformance/spreadObjectOrFalsy.types.diff b/testdata/baselines/reference/submodule/conformance/spreadObjectOrFalsy.types.diff index eb41bf49a8..c53237d855 100644 --- a/testdata/baselines/reference/submodule/conformance/spreadObjectOrFalsy.types.diff +++ b/testdata/baselines/reference/submodule/conformance/spreadObjectOrFalsy.types.diff @@ -17,16 +17,21 @@ } function f3(a: T) { -@@= skipped -18, +18 lines =@@ - } +@@= skipped -19, +19 lines =@@ function f4(a: object | T) { -->f4 : (a: object | T) => {} -+>f4 : (a: T | object) => {} - >a : T | object + >f4 : (a: object | T) => {} +->a : T | object ++>a : object | T return { ...a }; -@@= skipped -29, +29 lines =@@ + >{ ...a } : {} +->a : T | object ++>a : object | T + } + + function f5(a: S | T) { +@@= skipped -28, +28 lines =@@ // Repro from #46976 function g1(a: A) { diff --git a/testdata/baselines/reference/submodule/conformance/templateLiteralTypes3.types b/testdata/baselines/reference/submodule/conformance/templateLiteralTypes3.types index ccb68885a0..6f2290166e 100644 --- a/testdata/baselines/reference/submodule/conformance/templateLiteralTypes3.types +++ b/testdata/baselines/reference/submodule/conformance/templateLiteralTypes3.types @@ -608,16 +608,16 @@ function a() { >id : string let x: keyof T & string | `-${keyof T & string}`; ->x : keyof T & string | `-${keyof T & string}` +>x : `-${keyof T & string}` | keyof T & string x = "id"; >x = "id" : "id" ->x : keyof T & string | `-${keyof T & string}` +>x : `-${keyof T & string}` | keyof T & string >"id" : "id" x = "-id"; >x = "-id" : "-id" ->x : keyof T & string | `-${keyof T & string}` +>x : `-${keyof T & string}` | keyof T & string >"-id" : "-id" } diff --git a/testdata/baselines/reference/submodule/conformance/templateLiteralTypes3.types.diff b/testdata/baselines/reference/submodule/conformance/templateLiteralTypes3.types.diff index 1b3a813aef..a80b9d28ec 100644 --- a/testdata/baselines/reference/submodule/conformance/templateLiteralTypes3.types.diff +++ b/testdata/baselines/reference/submodule/conformance/templateLiteralTypes3.types.diff @@ -112,17 +112,17 @@ let x: keyof T & string | `-${keyof T & string}`; ->x : (keyof T & string) | `-${keyof T & string}` -+>x : keyof T & string | `-${keyof T & string}` ++>x : `-${keyof T & string}` | keyof T & string x = "id"; >x = "id" : "id" ->x : (keyof T & string) | `-${keyof T & string}` -+>x : keyof T & string | `-${keyof T & string}` ++>x : `-${keyof T & string}` | keyof T & string >"id" : "id" x = "-id"; >x = "-id" : "-id" ->x : (keyof T & string) | `-${keyof T & string}` -+>x : keyof T & string | `-${keyof T & string}` ++>x : `-${keyof T & string}` | keyof T & string >"-id" : "-id" } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumTagOnObjectFrozen.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumTagOnObjectFrozen.types.diff index 8ba89ee226..9bbf9a36b2 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumTagOnObjectFrozen.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumTagOnObjectFrozen.types.diff @@ -40,10 +40,10 @@ >Thing : Readonly<{ a: "thing"; b: "chill"; }> >Object.freeze({ a: "thing", b: "chill"}) : Readonly<{ a: "thing"; b: "chill"; }> ->Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>Object.freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >Object : ObjectConstructor ->freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } -+>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } ++>freeze : { (f: T): T; (o: T): Readonly; (o: T): Readonly; } >{ a: "thing", b: "chill"} : { a: "thing"; b: "chill"; } a: "thing", diff --git a/testdata/tests/cases/compiler/objectSubtypeReduction.ts b/testdata/tests/cases/compiler/objectSubtypeReduction.ts new file mode 100644 index 0000000000..65ba68d8c0 --- /dev/null +++ b/testdata/tests/cases/compiler/objectSubtypeReduction.ts @@ -0,0 +1,10 @@ +// @strict: true +// @target: esnext +// @noEmit: true + +// https://github.com/microsoft/typescript-go/issues/1164 + +function foo(x?: object) { + return Object.entries(x || {}) + .sort(([k1, v1], [k2, v2]) => v1.name.localeCompare(v2.name)); +}