Skip to content

Commit d7434a0

Browse files
Accepted baselines.
1 parent d9e8246 commit d7434a0

13 files changed

+101
-74
lines changed

tests/baselines/reference/genericIsNeverEmptyObject.types

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
// Repro from #29067
33

44
function test<T extends { a: string }>(obj: T) {
5-
>test : <T extends { a: string; }>(obj: T) => Omit<T, "a"> & { b: string; }
5+
>test : <T extends { a: string; }>(obj: T) => Pick<T, Exclude<keyof T, "a">> & { b: string; }
66
>a : string
77
>obj : T
88

99
let { a, ...rest } = obj;
1010
>a : string
11-
>rest : Omit<T, "a">
11+
>rest : Pick<T, Exclude<keyof T, "a">>
1212
>obj : T
1313

1414
return { ...rest, b: a };
15-
>{ ...rest, b: a } : Omit<T, "a"> & { b: string; }
16-
>rest : Omit<T, "a">
15+
>{ ...rest, b: a } : Pick<T, Exclude<keyof T, "a">> & { b: string; }
16+
>rest : Pick<T, Exclude<keyof T, "a">>
1717
>b : string
1818
>a : string
1919
}
@@ -30,7 +30,7 @@ let o2: { b: string, x: number } = test(o1);
3030
>o2 : { b: string; x: number; }
3131
>b : string
3232
>x : number
33-
>test(o1) : Omit<{ a: string; x: number; }, "a"> & { b: string; }
34-
>test : <T extends { a: string; }>(obj: T) => Omit<T, "a"> & { b: string; }
33+
>test(o1) : Pick<{ a: string; x: number; }, "x"> & { b: string; }
34+
>test : <T extends { a: string; }>(obj: T) => Pick<T, Exclude<keyof T, "a">> & { b: string; }
3535
>o1 : { a: string; x: number; }
3636

tests/baselines/reference/genericObjectRest.types

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,32 @@ function f1<T extends { a: string, b: number }>(obj: T) {
1616
let { a: a1, ...r1 } = obj;
1717
>a : any
1818
>a1 : string
19-
>r1 : Omit<T, "a">
19+
>r1 : Pick<T, Exclude<keyof T, "a">>
2020
>obj : T
2121

2222
let { a: a2, b: b2, ...r2 } = obj;
2323
>a : any
2424
>a2 : string
2525
>b : any
2626
>b2 : number
27-
>r2 : Omit<T, "a" | "b">
27+
>r2 : Pick<T, Exclude<keyof T, "a" | "b">>
2828
>obj : T
2929

3030
let { 'a': a3, ...r3 } = obj;
3131
>a3 : string
32-
>r3 : Omit<T, "a">
32+
>r3 : Pick<T, Exclude<keyof T, "a">>
3333
>obj : T
3434

3535
let { ['a']: a4, ...r4 } = obj;
3636
>'a' : "a"
3737
>a4 : string
38-
>r4 : Omit<T, "a">
38+
>r4 : Pick<T, Exclude<keyof T, "a">>
3939
>obj : T
4040

4141
let { [a]: a5, ...r5 } = obj;
4242
>a : "a"
4343
>a5 : string
44-
>r5 : Omit<T, "a">
44+
>r5 : Pick<T, Exclude<keyof T, "a">>
4545
>obj : T
4646
}
4747

@@ -68,7 +68,7 @@ function f2<T extends { [sa]: string, [sb]: number }>(obj: T) {
6868
>a1 : string
6969
>sb : unique symbol
7070
>b1 : number
71-
>r1 : Omit<T, unique symbol | unique symbol>
71+
>r1 : Pick<T, Exclude<keyof T, unique symbol | unique symbol>>
7272
>obj : T
7373
}
7474

@@ -83,7 +83,7 @@ function f3<T, K1 extends keyof T, K2 extends keyof T>(obj: T, k1: K1, k2: K2) {
8383
>a1 : T[K1]
8484
>k2 : K2
8585
>a2 : T[K2]
86-
>r1 : Omit<T, K1 | K2>
86+
>r1 : Pick<T, Exclude<keyof T, K1 | K2>>
8787
>obj : T
8888
}
8989

@@ -104,7 +104,7 @@ function f4<K1 extends keyof Item, K2 extends keyof Item>(obj: Item, k1: K1, k2:
104104
>a1 : Item[K1]
105105
>k2 : K2
106106
>a2 : Item[K2]
107-
>r1 : Omit<Item, K1 | K2>
107+
>r1 : Pick<Item, Exclude<"a", K1 | K2> | Exclude<"b", K1 | K2> | Exclude<"c", K1 | K2>>
108108
>obj : Item
109109
}
110110

tests/baselines/reference/literalTypeWidening.types

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,14 +443,14 @@ function test<T extends { a: string, b: string }>(obj: T): T {
443443

444444
let { a, ...rest } = obj;
445445
>a : string
446-
>rest : Omit<T, "a">
446+
>rest : Pick<T, Exclude<keyof T, "a">>
447447
>obj : T
448448

449449
return { a: 'hello', ...rest } as T;
450450
>{ a: 'hello', ...rest } as T : T
451-
>{ a: 'hello', ...rest } : { a: string; } & Omit<T, "a">
451+
>{ a: 'hello', ...rest } : { a: string; } & Pick<T, Exclude<keyof T, "a">>
452452
>a : string
453453
>'hello' : "hello"
454-
>rest : Omit<T, "a">
454+
>rest : Pick<T, Exclude<keyof T, "a">>
455455
}
456456

tests/baselines/reference/mappedTypeConstraints.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ const modifier = <T extends TargetProps>(targetProps: T) => {
132132
>targetProps : Symbol(targetProps, Decl(mappedTypeConstraints.ts, 30, 41))
133133

134134
rest.foo;
135-
>rest.foo : Symbol(foo)
135+
>rest.foo : Symbol(foo, Decl(mappedTypeConstraints.ts, 25, 20))
136136
>rest : Symbol(rest, Decl(mappedTypeConstraints.ts, 31, 13))
137-
>foo : Symbol(foo)
137+
>foo : Symbol(foo, Decl(mappedTypeConstraints.ts, 25, 20))
138138

139139
};
140140

tests/baselines/reference/mappedTypeConstraints.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ const modifier = <T extends TargetProps>(targetProps: T) => {
9898

9999
let {bar, ...rest} = targetProps;
100100
>bar : string
101-
>rest : Omit<T, "bar">
101+
>rest : Pick<T, Exclude<keyof T, "bar">>
102102
>targetProps : T
103103

104104
rest.foo;
105105
>rest.foo : T["foo"]
106-
>rest : Omit<T, "bar">
106+
>rest : Pick<T, Exclude<keyof T, "bar">>
107107
>foo : T["foo"]
108108

109109
};

tests/baselines/reference/objectRestNegative.types

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@ function stillMustBeLast({ ...mustBeLast, a }: { a: number, b: string }): void {
3636
>b : string
3737
}
3838
function generic<T extends { x, y }>(t: T) {
39-
>generic : <T extends { x: any; y: any; }>(t: T) => Omit<T, "x">
39+
>generic : <T extends { x: any; y: any; }>(t: T) => Pick<T, Exclude<keyof T, "x">>
4040
>x : any
4141
>y : any
4242
>t : T
4343

4444
let { x, ...rest } = t;
4545
>x : any
46-
>rest : Omit<T, "x">
46+
>rest : Pick<T, Exclude<keyof T, "x">>
4747
>t : T
4848

4949
return rest;
50-
>rest : Omit<T, "x">
50+
>rest : Pick<T, Exclude<keyof T, "x">>
5151
}
5252

5353
let rest: { b: string }
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
tests/cases/compiler/omitTypeHelperModifiers01.ts(16,7): error TS2540: Cannot assign to 'c' because it is a read-only property.
2+
3+
4+
==== tests/cases/compiler/omitTypeHelperModifiers01.ts (1 errors) ====
5+
type A = {
6+
a: number;
7+
b?: string;
8+
readonly c: boolean;
9+
d: unknown;
10+
};
11+
12+
type B = Omit<A, 'a'>;
13+
14+
function f(x: B) {
15+
const b = x.b;
16+
x.b = "hello";
17+
x.b = undefined;
18+
19+
const c = x.c;
20+
x.c = true;
21+
~
22+
!!! error TS2540: Cannot assign to 'c' because it is a read-only property.
23+
24+
const d = x.d;
25+
x.d = d;
26+
}
27+

tests/baselines/reference/omitTypeHelperModifiers01.symbols

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,42 +28,42 @@ function f(x: B) {
2828

2929
const b = x.b;
3030
>b : Symbol(b, Decl(omitTypeHelperModifiers01.ts, 10, 9))
31-
>x.b : Symbol(b)
31+
>x.b : Symbol(b, Decl(omitTypeHelperModifiers01.ts, 1, 14))
3232
>x : Symbol(x, Decl(omitTypeHelperModifiers01.ts, 9, 11))
33-
>b : Symbol(b)
33+
>b : Symbol(b, Decl(omitTypeHelperModifiers01.ts, 1, 14))
3434

3535
x.b = "hello";
36-
>x.b : Symbol(b)
36+
>x.b : Symbol(b, Decl(omitTypeHelperModifiers01.ts, 1, 14))
3737
>x : Symbol(x, Decl(omitTypeHelperModifiers01.ts, 9, 11))
38-
>b : Symbol(b)
38+
>b : Symbol(b, Decl(omitTypeHelperModifiers01.ts, 1, 14))
3939

4040
x.b = undefined;
41-
>x.b : Symbol(b)
41+
>x.b : Symbol(b, Decl(omitTypeHelperModifiers01.ts, 1, 14))
4242
>x : Symbol(x, Decl(omitTypeHelperModifiers01.ts, 9, 11))
43-
>b : Symbol(b)
43+
>b : Symbol(b, Decl(omitTypeHelperModifiers01.ts, 1, 14))
4444
>undefined : Symbol(undefined)
4545

4646
const c = x.c;
4747
>c : Symbol(c, Decl(omitTypeHelperModifiers01.ts, 14, 9))
48-
>x.c : Symbol(c)
48+
>x.c : Symbol(c, Decl(omitTypeHelperModifiers01.ts, 2, 15))
4949
>x : Symbol(x, Decl(omitTypeHelperModifiers01.ts, 9, 11))
50-
>c : Symbol(c)
50+
>c : Symbol(c, Decl(omitTypeHelperModifiers01.ts, 2, 15))
5151

5252
x.c = true;
53-
>x.c : Symbol(c)
53+
>x.c : Symbol(c, Decl(omitTypeHelperModifiers01.ts, 2, 15))
5454
>x : Symbol(x, Decl(omitTypeHelperModifiers01.ts, 9, 11))
55-
>c : Symbol(c)
55+
>c : Symbol(c, Decl(omitTypeHelperModifiers01.ts, 2, 15))
5656

5757
const d = x.d;
5858
>d : Symbol(d, Decl(omitTypeHelperModifiers01.ts, 17, 9))
59-
>x.d : Symbol(d)
59+
>x.d : Symbol(d, Decl(omitTypeHelperModifiers01.ts, 3, 24))
6060
>x : Symbol(x, Decl(omitTypeHelperModifiers01.ts, 9, 11))
61-
>d : Symbol(d)
61+
>d : Symbol(d, Decl(omitTypeHelperModifiers01.ts, 3, 24))
6262

6363
x.d = d;
64-
>x.d : Symbol(d)
64+
>x.d : Symbol(d, Decl(omitTypeHelperModifiers01.ts, 3, 24))
6565
>x : Symbol(x, Decl(omitTypeHelperModifiers01.ts, 9, 11))
66-
>d : Symbol(d)
66+
>d : Symbol(d, Decl(omitTypeHelperModifiers01.ts, 3, 24))
6767
>d : Symbol(d, Decl(omitTypeHelperModifiers01.ts, 17, 9))
6868
}
6969

tests/baselines/reference/omitTypeHelperModifiers01.types

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,55 +17,55 @@ type A = {
1717
};
1818

1919
type B = Omit<A, 'a'>;
20-
>B : Omit<A, "a">
20+
>B : Pick<A, "b" | "c" | "d">
2121

2222
function f(x: B) {
23-
>f : (x: Omit<A, "a">) => void
24-
>x : Omit<A, "a">
23+
>f : (x: Pick<A, "b" | "c" | "d">) => void
24+
>x : Pick<A, "b" | "c" | "d">
2525

2626
const b = x.b;
2727
>b : string | undefined
2828
>x.b : string | undefined
29-
>x : Omit<A, "a">
29+
>x : Pick<A, "b" | "c" | "d">
3030
>b : string | undefined
3131

3232
x.b = "hello";
3333
>x.b = "hello" : "hello"
3434
>x.b : string | undefined
35-
>x : Omit<A, "a">
35+
>x : Pick<A, "b" | "c" | "d">
3636
>b : string | undefined
3737
>"hello" : "hello"
3838

3939
x.b = undefined;
4040
>x.b = undefined : undefined
4141
>x.b : string | undefined
42-
>x : Omit<A, "a">
42+
>x : Pick<A, "b" | "c" | "d">
4343
>b : string | undefined
4444
>undefined : undefined
4545

4646
const c = x.c;
4747
>c : boolean
4848
>x.c : boolean
49-
>x : Omit<A, "a">
49+
>x : Pick<A, "b" | "c" | "d">
5050
>c : boolean
5151

5252
x.c = true;
5353
>x.c = true : true
54-
>x.c : boolean
55-
>x : Omit<A, "a">
56-
>c : boolean
54+
>x.c : any
55+
>x : Pick<A, "b" | "c" | "d">
56+
>c : any
5757
>true : true
5858

5959
const d = x.d;
6060
>d : unknown
6161
>x.d : unknown
62-
>x : Omit<A, "a">
62+
>x : Pick<A, "b" | "c" | "d">
6363
>d : unknown
6464

6565
x.d = d;
6666
>x.d = d : unknown
6767
>x.d : unknown
68-
>x : Omit<A, "a">
68+
>x : Pick<A, "b" | "c" | "d">
6969
>d : unknown
7070
>d : unknown
7171
}

tests/baselines/reference/omitTypeTestErrors01.errors.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
tests/cases/compiler/omitTypeTestErrors01.ts(11,16): error TS2339: Property 'c' does not exist on type 'Omit<Foo, "c">'.
2-
tests/cases/compiler/omitTypeTestErrors01.ts(15,16): error TS2339: Property 'b' does not exist on type 'Omit<Foo, "c" | "b">'.
1+
tests/cases/compiler/omitTypeTestErrors01.ts(11,16): error TS2339: Property 'c' does not exist on type 'Pick<Foo, "a" | "b">'.
2+
tests/cases/compiler/omitTypeTestErrors01.ts(15,16): error TS2339: Property 'b' does not exist on type 'Pick<Foo, "a">'.
33

44

55
==== tests/cases/compiler/omitTypeTestErrors01.ts (2 errors) ====
@@ -15,13 +15,13 @@ tests/cases/compiler/omitTypeTestErrors01.ts(15,16): error TS2339: Property 'b'
1515
export function getBarC(bar: Bar) {
1616
return bar.c;
1717
~
18-
!!! error TS2339: Property 'c' does not exist on type 'Omit<Foo, "c">'.
18+
!!! error TS2339: Property 'c' does not exist on type 'Pick<Foo, "a" | "b">'.
1919
}
2020

2121
export function getBazB(baz: Baz) {
2222
return baz.b;
2323
~
24-
!!! error TS2339: Property 'b' does not exist on type 'Omit<Foo, "c" | "b">'.
24+
!!! error TS2339: Property 'b' does not exist on type 'Pick<Foo, "a">'.
2525
}
2626

2727

tests/baselines/reference/omitTypeTestErrors01.types

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@ interface Foo {
1111
}
1212

1313
export type Bar = Omit<Foo, "c">;
14-
>Bar : Omit<Foo, "c">
14+
>Bar : Pick<Foo, "a" | "b">
1515

1616
export type Baz = Omit<Foo, "b" | "c">;
17-
>Baz : Omit<Foo, "c" | "b">
17+
>Baz : Pick<Foo, "a">
1818

1919
export function getBarC(bar: Bar) {
20-
>getBarC : (bar: Omit<Foo, "c">) => any
21-
>bar : Omit<Foo, "c">
20+
>getBarC : (bar: Pick<Foo, "a" | "b">) => any
21+
>bar : Pick<Foo, "a" | "b">
2222

2323
return bar.c;
2424
>bar.c : any
25-
>bar : Omit<Foo, "c">
25+
>bar : Pick<Foo, "a" | "b">
2626
>c : any
2727
}
2828

2929
export function getBazB(baz: Baz) {
30-
>getBazB : (baz: Omit<Foo, "c" | "b">) => any
31-
>baz : Omit<Foo, "c" | "b">
30+
>getBazB : (baz: Pick<Foo, "a">) => any
31+
>baz : Pick<Foo, "a">
3232

3333
return baz.b;
3434
>baz.b : any
35-
>baz : Omit<Foo, "c" | "b">
35+
>baz : Pick<Foo, "a">
3636
>b : any
3737
}
3838

0 commit comments

Comments
 (0)