Skip to content

Commit 241b3f2

Browse files
Accepted baselines.
1 parent 4d51879 commit 241b3f2

11 files changed

+94
-75
lines changed

tests/baselines/reference/circularContextualReturnType.types

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
// Repro from #17711
33

44
Object.freeze({
5-
>Object.freeze({ foo() { return Object.freeze('a'); },}) : Readonly<{ foo(): string; }>
6-
>Object.freeze : { <T extends Function>(f: T): T; <T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
5+
>Object.freeze({ foo() { return Object.freeze('a'); },}) : Readonly<{ readonly foo: () => "a"; }>
6+
>Object.freeze : { <T extends Function>(f: T): T; <const T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <const T>(o: T): Readonly<T>; }
77
>Object : ObjectConstructor
8-
>freeze : { <T extends Function>(f: T): T; <T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
9-
>{ foo() { return Object.freeze('a'); },} : { foo(): string; }
8+
>freeze : { <T extends Function>(f: T): T; <const T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <const T>(o: T): Readonly<T>; }
9+
>{ foo() { return Object.freeze('a'); },} : { foo(): "a"; }
1010

1111
foo() {
12-
>foo : () => string
12+
>foo : () => "a"
1313

1414
return Object.freeze('a');
15-
>Object.freeze('a') : string
16-
>Object.freeze : { <T extends Function>(f: T): T; <T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
15+
>Object.freeze('a') : "a"
16+
>Object.freeze : { <T extends Function>(f: T): T; <const T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <const T>(o: T): Readonly<T>; }
1717
>Object : ObjectConstructor
18-
>freeze : { <T extends Function>(f: T): T; <T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
18+
>freeze : { <T extends Function>(f: T): T; <const T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <const T>(o: T): Readonly<T>; }
1919
>'a' : "a"
2020

2121
},

tests/baselines/reference/completionsStringMethods.baseline

+2-2
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@
11051105
"target": {
11061106
"fileName": "lib.d.ts",
11071107
"textSpan": {
1108-
"start": 18529,
1108+
"start": 18541,
11091109
"length": 28
11101110
}
11111111
}
@@ -1128,7 +1128,7 @@
11281128
"target": {
11291129
"fileName": "lib.d.ts",
11301130
"textSpan": {
1131-
"start": 18529,
1131+
"start": 18541,
11321132
"length": 28
11331133
}
11341134
}

tests/baselines/reference/contextualSignatureInObjectFreeze.types

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// #49101
33

44
Object.freeze({
5-
>Object.freeze({ f: function () { }}) : Readonly<{ f: () => void; }>
6-
>Object.freeze : { <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
5+
>Object.freeze({ f: function () { }}) : Readonly<{ readonly f: () => void; }>
6+
>Object.freeze : { <T extends Function>(f: T): T; <const T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <const T>(o: T): Readonly<T>; }
77
>Object : ObjectConstructor
8-
>freeze : { <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
8+
>freeze : { <T extends Function>(f: T): T; <const T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <const T>(o: T): Readonly<T>; }
99
>{ f: function () { }} : { f: () => void; }
1010

1111
f: function () { }

tests/baselines/reference/jsEnumTagOnObjectFrozen.types

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
=== tests/cases/compiler/usage.js ===
22
const { Thing, useThing, cbThing } = require("./index");
3-
>Thing : Readonly<{ a: "thing"; b: "chill"; }>
3+
>Thing : Readonly<{ readonly a: "thing"; readonly b: "chill"; }>
44
>useThing : (x: string) => void
55
>cbThing : (x: (x: string) => void) => void
66
>require("./index") : typeof import("tests/cases/compiler/index")
@@ -11,7 +11,7 @@ useThing(Thing.a);
1111
>useThing(Thing.a) : void
1212
>useThing : (x: string) => void
1313
>Thing.a : "thing"
14-
>Thing : Readonly<{ a: "thing"; b: "chill"; }>
14+
>Thing : Readonly<{ readonly a: "thing"; readonly b: "chill"; }>
1515
>a : "thing"
1616

1717
/**
@@ -47,11 +47,11 @@ cbThing(type => {
4747
=== tests/cases/compiler/index.js ===
4848
/** @enum {string} */
4949
const Thing = Object.freeze({
50-
>Thing : Readonly<{ a: "thing"; b: "chill"; }>
51-
>Object.freeze({ a: "thing", b: "chill"}) : Readonly<{ a: "thing"; b: "chill"; }>
52-
>Object.freeze : { <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
50+
>Thing : Readonly<{ readonly a: "thing"; readonly b: "chill"; }>
51+
>Object.freeze({ a: "thing", b: "chill"}) : Readonly<{ readonly a: "thing"; readonly b: "chill"; }>
52+
>Object.freeze : { <T extends Function>(f: T): T; <const T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <const T>(o: T): Readonly<T>; }
5353
>Object : ObjectConstructor
54-
>freeze : { <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
54+
>freeze : { <T extends Function>(f: T): T; <const T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <const T>(o: T): Readonly<T>; }
5555
>{ a: "thing", b: "chill"} : { a: "thing"; b: "chill"; }
5656

5757
a: "thing",
@@ -65,11 +65,11 @@ const Thing = Object.freeze({
6565
});
6666

6767
exports.Thing = Thing;
68-
>exports.Thing = Thing : Readonly<{ a: "thing"; b: "chill"; }>
69-
>exports.Thing : Readonly<{ a: "thing"; b: "chill"; }>
68+
>exports.Thing = Thing : Readonly<{ readonly a: "thing"; readonly b: "chill"; }>
69+
>exports.Thing : Readonly<{ readonly a: "thing"; readonly b: "chill"; }>
7070
>exports : typeof import("tests/cases/compiler/index")
71-
>Thing : Readonly<{ a: "thing"; b: "chill"; }>
72-
>Thing : Readonly<{ a: "thing"; b: "chill"; }>
71+
>Thing : Readonly<{ readonly a: "thing"; readonly b: "chill"; }>
72+
>Thing : Readonly<{ readonly a: "thing"; readonly b: "chill"; }>
7373

7474
/**
7575
* @param {Thing} x

tests/baselines/reference/keyofAndIndexedAccess.types

+2-2
Original file line numberDiff line numberDiff line change
@@ -1876,9 +1876,9 @@ class SampleClass<P> {
18761876
>this : this
18771877
>props : Readonly<P>
18781878
>Object.freeze(props) : Readonly<P>
1879-
>Object.freeze : { <T extends Function>(f: T): T; <T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
1879+
>Object.freeze : { <T extends Function>(f: T): T; <const T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <const T>(o: T): Readonly<T>; }
18801880
>Object : ObjectConstructor
1881-
>freeze : { <T extends Function>(f: T): T; <T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
1881+
>freeze : { <T extends Function>(f: T): T; <const T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <const T>(o: T): Readonly<T>; }
18821882
>props : P
18831883
}
18841884
}

tests/baselines/reference/objectFreeze.errors.txt

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
tests/cases/compiler/objectFreeze.ts(9,1): error TS2322: Type 'string' is not assignable to type 'number'.
2-
tests/cases/compiler/objectFreeze.ts(9,1): error TS2542: Index signature in type 'readonly number[]' only permits reading.
1+
tests/cases/compiler/objectFreeze.ts(9,3): error TS2540: Cannot assign to '0' because it is a read-only property.
32
tests/cases/compiler/objectFreeze.ts(12,3): error TS2540: Cannot assign to 'b' because it is a read-only property.
43

54

6-
==== tests/cases/compiler/objectFreeze.ts (3 errors) ====
5+
==== tests/cases/compiler/objectFreeze.ts (2 errors) ====
76
const f = Object.freeze(function foo(a: number, b: string) { return false; });
87
f(1, "") === false;
98

@@ -13,10 +12,8 @@ tests/cases/compiler/objectFreeze.ts(12,3): error TS2540: Cannot assign to 'b' b
1312

1413
const a = Object.freeze([1, 2, 3]);
1514
a[0] = a[2].toString();
16-
~~~~
17-
!!! error TS2322: Type 'string' is not assignable to type 'number'.
18-
~~~~
19-
!!! error TS2542: Index signature in type 'readonly number[]' only permits reading.
15+
~
16+
!!! error TS2540: Cannot assign to '0' because it is a read-only property.
2017

2118
const o = Object.freeze({ a: 1, b: "string", c: true });
2219
o.b = o.a.toString();

tests/baselines/reference/objectFreeze.symbols

+2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ const a = Object.freeze([1, 2, 3]);
3333

3434
a[0] = a[2].toString();
3535
>a : Symbol(a, Decl(objectFreeze.ts, 7, 5))
36+
>0 : Symbol(0)
3637
>a[2].toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
3738
>a : Symbol(a, Decl(objectFreeze.ts, 7, 5))
39+
>2 : Symbol(2)
3840
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
3941

4042
const o = Object.freeze({ a: 1, b: "string", c: true });

tests/baselines/reference/objectFreeze.types

+19-19
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
const f = Object.freeze(function foo(a: number, b: string) { return false; });
33
>f : (a: number, b: string) => false
44
>Object.freeze(function foo(a: number, b: string) { return false; }) : (a: number, b: string) => false
5-
>Object.freeze : { <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
5+
>Object.freeze : { <T extends Function>(f: T): T; <const T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <const T>(o: T): Readonly<T>; }
66
>Object : ObjectConstructor
7-
>freeze : { <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
7+
>freeze : { <T extends Function>(f: T): T; <const T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <const T>(o: T): Readonly<T>; }
88
>function foo(a: number, b: string) { return false; } : (a: number, b: string) => false
99
>foo : (a: number, b: string) => false
1010
>a : number
@@ -26,9 +26,9 @@ class C { constructor(a: number) { } }
2626
const c = Object.freeze(C);
2727
>c : typeof C
2828
>Object.freeze(C) : typeof C
29-
>Object.freeze : { <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
29+
>Object.freeze : { <T extends Function>(f: T): T; <const T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <const T>(o: T): Readonly<T>; }
3030
>Object : ObjectConstructor
31-
>freeze : { <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
31+
>freeze : { <T extends Function>(f: T): T; <const T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <const T>(o: T): Readonly<T>; }
3232
>C : typeof C
3333

3434
new c(1);
@@ -37,34 +37,34 @@ new c(1);
3737
>1 : 1
3838

3939
const a = Object.freeze([1, 2, 3]);
40-
>a : readonly number[]
41-
>Object.freeze([1, 2, 3]) : readonly number[]
42-
>Object.freeze : { <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
40+
>a : readonly [1, 2, 3]
41+
>Object.freeze([1, 2, 3]) : readonly [1, 2, 3]
42+
>Object.freeze : { <T extends Function>(f: T): T; <const T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <const T>(o: T): Readonly<T>; }
4343
>Object : ObjectConstructor
44-
>freeze : { <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
45-
>[1, 2, 3] : number[]
44+
>freeze : { <T extends Function>(f: T): T; <const T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <const T>(o: T): Readonly<T>; }
45+
>[1, 2, 3] : [1, 2, 3]
4646
>1 : 1
4747
>2 : 2
4848
>3 : 3
4949

5050
a[0] = a[2].toString();
5151
>a[0] = a[2].toString() : string
52-
>a[0] : number
53-
>a : readonly number[]
52+
>a[0] : any
53+
>a : readonly [1, 2, 3]
5454
>0 : 0
5555
>a[2].toString() : string
5656
>a[2].toString : (radix?: number) => string
57-
>a[2] : number
58-
>a : readonly number[]
57+
>a[2] : 3
58+
>a : readonly [1, 2, 3]
5959
>2 : 2
6060
>toString : (radix?: number) => string
6161

6262
const o = Object.freeze({ a: 1, b: "string", c: true });
63-
>o : Readonly<{ a: 1; b: "string"; c: true; }>
64-
>Object.freeze({ a: 1, b: "string", c: true }) : Readonly<{ a: 1; b: "string"; c: true; }>
65-
>Object.freeze : { <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
63+
>o : Readonly<{ readonly a: 1; readonly b: "string"; readonly c: true; }>
64+
>Object.freeze({ a: 1, b: "string", c: true }) : Readonly<{ readonly a: 1; readonly b: "string"; readonly c: true; }>
65+
>Object.freeze : { <T extends Function>(f: T): T; <const T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <const T>(o: T): Readonly<T>; }
6666
>Object : ObjectConstructor
67-
>freeze : { <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
67+
>freeze : { <T extends Function>(f: T): T; <const T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <const T>(o: T): Readonly<T>; }
6868
>{ a: 1, b: "string", c: true } : { a: 1; b: "string"; c: true; }
6969
>a : 1
7070
>1 : 1
@@ -76,12 +76,12 @@ const o = Object.freeze({ a: 1, b: "string", c: true });
7676
o.b = o.a.toString();
7777
>o.b = o.a.toString() : string
7878
>o.b : any
79-
>o : Readonly<{ a: 1; b: "string"; c: true; }>
79+
>o : Readonly<{ readonly a: 1; readonly b: "string"; readonly c: true; }>
8080
>b : any
8181
>o.a.toString() : string
8282
>o.a.toString : (radix?: number) => string
8383
>o.a : 1
84-
>o : Readonly<{ a: 1; b: "string"; c: true; }>
84+
>o : Readonly<{ readonly a: 1; readonly b: "string"; readonly c: true; }>
8585
>a : 1
8686
>toString : (radix?: number) => string
8787

tests/baselines/reference/objectFreezeLiteralsDontWiden.types

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
=== tests/cases/compiler/objectFreezeLiteralsDontWiden.ts ===
22
const PUPPETEER_REVISIONS = Object.freeze({
3-
>PUPPETEER_REVISIONS : Readonly<{ chromium: "1011831"; firefox: "latest"; }>
4-
>Object.freeze({ chromium: '1011831', firefox: 'latest',}) : Readonly<{ chromium: "1011831"; firefox: "latest"; }>
5-
>Object.freeze : { <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
3+
>PUPPETEER_REVISIONS : Readonly<{ readonly chromium: "1011831"; readonly firefox: "latest"; }>
4+
>Object.freeze({ chromium: '1011831', firefox: 'latest',}) : Readonly<{ readonly chromium: "1011831"; readonly firefox: "latest"; }>
5+
>Object.freeze : { <T extends Function>(f: T): T; <const T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <const T>(o: T): Readonly<T>; }
66
>Object : ObjectConstructor
7-
>freeze : { <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
7+
>freeze : { <T extends Function>(f: T): T; <const T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <const T>(o: T): Readonly<T>; }
88
>{ chromium: '1011831', firefox: 'latest',} : { chromium: "1011831"; firefox: "latest"; }
99

1010
chromium: '1011831',
@@ -20,13 +20,13 @@ const PUPPETEER_REVISIONS = Object.freeze({
2020
let preferredRevision = PUPPETEER_REVISIONS.chromium;
2121
>preferredRevision : "1011831"
2222
>PUPPETEER_REVISIONS.chromium : "1011831"
23-
>PUPPETEER_REVISIONS : Readonly<{ chromium: "1011831"; firefox: "latest"; }>
23+
>PUPPETEER_REVISIONS : Readonly<{ readonly chromium: "1011831"; readonly firefox: "latest"; }>
2424
>chromium : "1011831"
2525

2626
preferredRevision = PUPPETEER_REVISIONS.firefox;
2727
>preferredRevision = PUPPETEER_REVISIONS.firefox : "latest"
2828
>preferredRevision : "1011831"
2929
>PUPPETEER_REVISIONS.firefox : "latest"
30-
>PUPPETEER_REVISIONS : Readonly<{ chromium: "1011831"; firefox: "latest"; }>
30+
>PUPPETEER_REVISIONS : Readonly<{ readonly chromium: "1011831"; readonly firefox: "latest"; }>
3131
>firefox : "latest"
3232

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
tests/cases/compiler/objectFromEntries.ts(8,7): error TS2322: Type 'readonly [readonly ["a", 1], readonly ["b", 2], readonly ["c", 3]]' is not assignable to type 'readonly [string, number][]'.
2+
Type 'readonly ["a", 1] | readonly ["b", 2] | readonly ["c", 3]' is not assignable to type '[string, number]'.
3+
The type 'readonly ["a", 1]' is 'readonly' and cannot be assigned to the mutable type '[string, number]'.
4+
5+
6+
==== tests/cases/compiler/objectFromEntries.ts (1 errors) ====
7+
const o = Object.fromEntries([['a', 1], ['b', 2], ['c', 3]]);
8+
const o2 = Object.fromEntries(new URLSearchParams());
9+
const o3 = Object.fromEntries(new Map([[Symbol("key"), "value"]]));
10+
11+
const frozenArray = Object.freeze([['a', 1], ['b', 2], ['c', 3]]);
12+
const o4 = Object.fromEntries(frozenArray);
13+
14+
const frozenArray2: readonly [string, number][] = Object.freeze([['a', 1], ['b', 2], ['c', 3]]);
15+
~~~~~~~~~~~~
16+
!!! error TS2322: Type 'readonly [readonly ["a", 1], readonly ["b", 2], readonly ["c", 3]]' is not assignable to type 'readonly [string, number][]'.
17+
!!! error TS2322: Type 'readonly ["a", 1] | readonly ["b", 2] | readonly ["c", 3]' is not assignable to type '[string, number]'.
18+
!!! error TS2322: The type 'readonly ["a", 1]' is 'readonly' and cannot be assigned to the mutable type '[string, number]'.
19+
const o5 = Object.fromEntries(frozenArray2);
20+

0 commit comments

Comments
 (0)