Skip to content

Commit f8ef137

Browse files
accept baseline
1 parent 4b90da7 commit f8ef137

20 files changed

Lines changed: 2215 additions & 2517 deletions

tests/baselines/reference/conditionalTypes1.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ conditionalTypes1.ts(288,43): error TS2322: Type 'T95<U>' is not assignable to t
9696
!!! error TS2322: Type 'T' is not assignable to type 'NonNullable<T>'.
9797
!!! error TS2322: Type 'T' is not assignable to type '{}'.
9898
!!! related TS2208 conditionalTypes1.ts:10:13: This type parameter might need an `extends {}` constraint.
99-
!!! related TS2208 conditionalTypes1.ts:10:13: This type parameter might need an `extends NonNullable<T>` constraint.
99+
!!! related TS2882 conditionalTypes1.ts:10:13: You might have swapped the left and right hand sides of the assignment.
100100
}
101101

102102
function f2<T extends string | undefined>(x: T, y: NonNullable<T>) {

tests/baselines/reference/dependentReturnType1.errors.txt

Lines changed: 162 additions & 28 deletions
Large diffs are not rendered by default.

tests/baselines/reference/dependentReturnType1.types

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,14 @@ function f101<T extends 1 | 2 | 3 | 4>(x: T): T extends 1 ? One : T extends 2 ?
308308
// Excess property becomes a problem with the change,
309309
// because we now check assignability to a narrower type...
310310
return { a: "a", b: "b", c: "c", d: "d", e: "e", f: "f", g: "g" }; // EPC Error
311-
>{ a: "a", b: "b", c: "c", d: "d", e: "e", f: "f", g: "g" } : { a: "a"; b: string; c: "c"; d: "d"; e: "e"; f: "f"; g: "g"; }
312-
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
311+
>{ a: "a", b: "b", c: "c", d: "d", e: "e", f: "f", g: "g" } : { a: "a"; b: "b"; c: "c"; d: "d"; e: "e"; f: "f"; g: "g"; }
312+
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
313313
>a : "a"
314314
> : ^^^
315315
>"a" : "a"
316316
> : ^^^
317-
>b : string
318-
> : ^^^^^^
317+
>b : "b"
318+
> : ^^^
319319
>"b" : "b"
320320
> : ^^^
321321
>c : "c"
@@ -777,16 +777,16 @@ function contextualConditional<T extends "a" | "b">(
777777

778778
): T extends "a" ? "a" : T extends "b" ? number : never {
779779
return x === "a" ? x : parseInt(x); // Ok
780-
>x === "a" ? x : parseInt(x) : number | "a"
781-
> : ^^^^^^^^^^^^
780+
>x === "a" ? x : parseInt(x) : number | T
781+
> : ^^^^^^^^^^
782782
>x === "a" : boolean
783783
> : ^^^^^^^
784784
>x : T
785785
> : ^
786786
>"a" : "a"
787787
> : ^^^
788-
>x : "a"
789-
> : ^^^
788+
>x : T
789+
> : ^
790790
>parseInt(x) : number
791791
> : ^^^^^^
792792
>parseInt : (string: string, radix?: number) => number
@@ -805,16 +805,16 @@ function conditionalWithError<T extends "a" | "b">(
805805

806806
): T extends "a" ? number : T extends "b" ? string : never {
807807
return x === "a" ? x : parseInt(x); // Error
808-
>x === "a" ? x : parseInt(x) : number | "a"
809-
> : ^^^^^^^^^^^^
808+
>x === "a" ? x : parseInt(x) : number | T
809+
> : ^^^^^^^^^^
810810
>x === "a" : boolean
811811
> : ^^^^^^^
812812
>x : T
813813
> : ^
814814
>"a" : "a"
815815
> : ^^^
816-
>x : "a"
817-
> : ^^^
816+
>x : T
817+
> : ^
818818
>parseInt(x) : number
819819
> : ^^^^^^
820820
>parseInt : (string: string, radix?: number) => number

tests/baselines/reference/dependentReturnType2.errors.txt

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,34 @@
1-
file.js(155,13): error TS2322: Type 'undefined' is not assignable to type 'HelperCond<I, string, T | undefined, RegExp, SettingComposedValue<T>[]>'.
1+
file.js(34,13): error TS2322: Type 'string' is not assignable to type 'T extends string ? string : T extends IMessage ? IMessage : never'.
2+
file.js(38,13): error TS2322: Type 'T' is not assignable to type 'T extends string ? string : T extends IMessage ? IMessage : never'.
3+
Type 'string | IMessage' is not assignable to type 'T extends string ? string : T extends IMessage ? IMessage : never'.
4+
Type 'string' is not assignable to type 'T extends string ? string : T extends IMessage ? IMessage : never'.
5+
file.js(46,9): error TS2322: Type 'T' is not assignable to type 'T extends string ? string : T extends IMessage ? IMessage : never'.
6+
Type 'string | IMessage' is not assignable to type 'T extends string ? string : T extends IMessage ? IMessage : never'.
7+
Type 'string' is not assignable to type 'T extends string ? string : T extends IMessage ? IMessage : never'.
8+
file.js(59,9): error TS2322: Type '(message: IMessage) => IMessage' is not assignable to type 'T extends true ? (message: IMessage) => IMessage : T extends false ? (message: string) => string : never'.
9+
file.js(61,5): error TS2322: Type '(message: string) => string' is not assignable to type 'T extends true ? (message: IMessage) => IMessage : T extends false ? (message: string) => string : never'.
10+
file.js(125,17): error TS2322: Type 'undefined' is not assignable to type 'HelperCond<C, SettingCallback, void, undefined, HelperCond<I, string, T | undefined, RegExp, SettingComposedValue<T>[]>>'.
11+
file.js(128,17): error TS2322: Type 'void' is not assignable to type 'HelperCond<C, SettingCallback, void, undefined, HelperCond<I, string, T | undefined, RegExp, SettingComposedValue<T>[]>>'.
12+
file.js(134,17): error TS2322: Type 'void' is not assignable to type 'HelperCond<C, SettingCallback, void, undefined, HelperCond<I, string, T | undefined, RegExp, SettingComposedValue<T>[]>>'.
13+
file.js(148,17): error TS2322: Type 'undefined' is not assignable to type 'HelperCond<C, SettingCallback, void, undefined, HelperCond<I, string, T | undefined, RegExp, SettingComposedValue<T>[]>>'.
14+
file.js(151,13): error TS2322: Type 'undefined' is not assignable to type 'HelperCond<C, SettingCallback, void, undefined, HelperCond<I, string, T | undefined, RegExp, SettingComposedValue<T>[]>>'.
15+
file.js(155,13): error TS2322: Type 'undefined' is not assignable to type 'HelperCond<C, SettingCallback, void, undefined, HelperCond<I, string, T | undefined, RegExp, SettingComposedValue<T>[]>>'.
16+
file.js(159,13): error TS2322: Type 'SettingComposedValue<T>[]' is not assignable to type 'HelperCond<C, SettingCallback, void, undefined, HelperCond<I, string, T | undefined, RegExp, SettingComposedValue<T>[]>>'.
217
file.js(168,16): error TS2536: Type 'I' cannot be used to index type '{ [s: string]: any; }'.
318
file.js(185,9): error TS2322: Type 'Record<string, MyObj[]>' is not assignable to type 'HelperCond<T, string, MyObj[], undefined, Record<string, MyObj[]>>'.
19+
file.js(187,5): error TS2322: Type 'MyObj[]' is not assignable to type 'HelperCond<T, string, MyObj[], undefined, Record<string, MyObj[]>>'.
20+
file.js(197,9): error TS2322: Type 'Record<string, MyObj[]>' is not assignable to type 'HelperCond<T, string, MyObj[], undefined, Record<string, MyObj[]>>'.
21+
file.js(199,5): error TS2322: Type 'MyObj[]' is not assignable to type 'HelperCond<T, string, MyObj[], undefined, Record<string, MyObj[]>>'.
22+
file.js(220,9): error TS2322: Type '{ start: Date; end: Date; }' is not assignable to type 'HelperCond<T, string, { start: Date; end: Date; }, undefined, { start: Date; end: undefined; }>'.
23+
file.js(224,9): error TS2322: Type '{ start: Date; end: undefined; }' is not assignable to type 'HelperCond<T, string, { start: Date; end: Date; }, undefined, { start: Date; end: undefined; }>'.
24+
file.js(277,13): error TS2322: Type 'MyObj' is not assignable to type 'HelperCond<T, string, MyObj, string[], MyObj[] | undefined>'.
25+
file.js(281,13): error TS2322: Type 'MyObj[] | undefined' is not assignable to type 'HelperCond<T, string, MyObj, string[], MyObj[] | undefined>'.
26+
Type 'undefined' is not assignable to type 'HelperCond<T, string, MyObj, string[], MyObj[] | undefined>'.
27+
file.js(296,24): error TS2322: Type 'null' is not assignable to type 'HelperCond<T, string, string, null | undefined, null>'.
28+
file.js(300,5): error TS2322: Type 'string' is not assignable to type 'HelperCond<T, string, string, null | undefined, null>'.
429

530

6-
==== file.js (3 errors) ====
31+
==== file.js (23 errors) ====
732
// Adapted from ts-error-deltas repos
833

934
/**
@@ -38,10 +63,16 @@ file.js(185,9): error TS2322: Type 'Record<string, MyObj[]>' is not assignable t
3863
renderMessage(message) {
3964
if (typeof message === 'string') {
4065
return this.render(message); // Ok
66+
~~~~~~
67+
!!! error TS2322: Type 'string' is not assignable to type 'T extends string ? string : T extends IMessage ? IMessage : never'.
4168
}
4269

4370
if (!message.html?.trim()) {
4471
return message; // Ok
72+
~~~~~~
73+
!!! error TS2322: Type 'T' is not assignable to type 'T extends string ? string : T extends IMessage ? IMessage : never'.
74+
!!! error TS2322: Type 'string | IMessage' is not assignable to type 'T extends string ? string : T extends IMessage ? IMessage : never'.
75+
!!! error TS2322: Type 'string' is not assignable to type 'T extends string ? string : T extends IMessage ? IMessage : never'.
4576
}
4677

4778
if (!message.tokens) {
@@ -50,6 +81,10 @@ file.js(185,9): error TS2322: Type 'Record<string, MyObj[]>' is not assignable t
5081

5182
message.html = this.render(message.html);
5283
return message; // Ok
84+
~~~~~~
85+
!!! error TS2322: Type 'T' is not assignable to type 'T extends string ? string : T extends IMessage ? IMessage : never'.
86+
!!! error TS2322: Type 'string | IMessage' is not assignable to type 'T extends string ? string : T extends IMessage ? IMessage : never'.
87+
!!! error TS2322: Type 'string' is not assignable to type 'T extends string ? string : T extends IMessage ? IMessage : never'.
5388
}
5489
}
5590

@@ -63,8 +98,12 @@ file.js(185,9): error TS2322: Type 'Record<string, MyObj[]>' is not assignable t
6398
const instance = new NewKatex();
6499
if (_isMessage) {
65100
return (/** @type {IMessage} */ message) => instance.renderMessage(message); // Ok
101+
~~~~~~
102+
!!! error TS2322: Type '(message: IMessage) => IMessage' is not assignable to type 'T extends true ? (message: IMessage) => IMessage : T extends false ? (message: string) => string : never'.
66103
}
67104
return (/** @type {string} */ message) => instance.renderMessage(message); // Ok
105+
~~~~~~
106+
!!! error TS2322: Type '(message: string) => string' is not assignable to type 'T extends true ? (message: IMessage) => IMessage : T extends false ? (message: string) => string : never'.
68107
}
69108

70109
// File: Rocket.Chat/apps/meteor/app/settings/lib/settings.ts
@@ -129,15 +168,21 @@ file.js(185,9): error TS2322: Type 'Record<string, MyObj[]>' is not assignable t
129168
if (callback !== undefined) {
130169
if (!Meteor.settings) {
131170
return; // Ok
171+
~~~~~~
172+
!!! error TS2322: Type 'undefined' is not assignable to type 'HelperCond<C, SettingCallback, void, undefined, HelperCond<I, string, T | undefined, RegExp, SettingComposedValue<T>[]>>'.
132173
}
133174
if (_id === '*') {
134175
return Object.keys(Meteor.settings).forEach((key) => {
176+
~~~~~~
177+
!!! error TS2322: Type 'void' is not assignable to type 'HelperCond<C, SettingCallback, void, undefined, HelperCond<I, string, T | undefined, RegExp, SettingComposedValue<T>[]>>'.
135178
const value = Meteor.settings[key];
136179
callback(key, value);
137180
});
138181
}
139182
if (_.isRegExp(_id) && Meteor.settings) {
140183
return Object.keys(Meteor.settings).forEach((key) => {
184+
~~~~~~
185+
!!! error TS2322: Type 'void' is not assignable to type 'HelperCond<C, SettingCallback, void, undefined, HelperCond<I, string, T | undefined, RegExp, SettingComposedValue<T>[]>>'.
141186
if (!_id.test(key)) {
142187
return;
143188
}
@@ -152,19 +197,25 @@ file.js(185,9): error TS2322: Type 'Record<string, MyObj[]>' is not assignable t
152197
callback(_id, Meteor.settings[_id]);
153198
}
154199
return; // Ok
200+
~~~~~~
201+
!!! error TS2322: Type 'undefined' is not assignable to type 'HelperCond<C, SettingCallback, void, undefined, HelperCond<I, string, T | undefined, RegExp, SettingComposedValue<T>[]>>'.
155202
}
156203

157204
return; // Ok, needed for exhaustiveness check
205+
~~~~~~
206+
!!! error TS2322: Type 'undefined' is not assignable to type 'HelperCond<C, SettingCallback, void, undefined, HelperCond<I, string, T | undefined, RegExp, SettingComposedValue<T>[]>>'.
158207
}
159208

160209
if (!Meteor.settings) {
161210
return undefined; // Error
162211
~~~~~~
163-
!!! error TS2322: Type 'undefined' is not assignable to type 'HelperCond<I, string, T | undefined, RegExp, SettingComposedValue<T>[]>'.
212+
!!! error TS2322: Type 'undefined' is not assignable to type 'HelperCond<C, SettingCallback, void, undefined, HelperCond<I, string, T | undefined, RegExp, SettingComposedValue<T>[]>>'.
164213
}
165214

166215
if (_.isRegExp(_id)) {
167216
return Object.keys(Meteor.settings).reduce((/** @type {SettingComposedValue<T>[]} */ items, key) => {
217+
~~~~~~
218+
!!! error TS2322: Type 'SettingComposedValue<T>[]' is not assignable to type 'HelperCond<C, SettingCallback, void, undefined, HelperCond<I, string, T | undefined, RegExp, SettingComposedValue<T>[]>>'.
168219
const value = Meteor.settings[key];
169220
if (_id.test(key)) {
170221
items.push({ key, value });
@@ -197,6 +248,8 @@ file.js(185,9): error TS2322: Type 'Record<string, MyObj[]>' is not assignable t
197248
!!! error TS2322: Type 'Record<string, MyObj[]>' is not assignable to type 'HelperCond<T, string, MyObj[], undefined, Record<string, MyObj[]>>'.
198249
}
199250
return /** @type {MessageBoxAction[]} */([]); // Ok
251+
~~~~~~
252+
!!! error TS2322: Type 'MyObj[]' is not assignable to type 'HelperCond<T, string, MyObj[], undefined, Record<string, MyObj[]>>'.
200253
}
201254

202255
/**
@@ -207,8 +260,12 @@ file.js(185,9): error TS2322: Type 'Record<string, MyObj[]>' is not assignable t
207260
function getWithoutBug(group) {
208261
if (group === undefined) {
209262
return /** @type {Record<string, MessageBoxAction[]>} */({}); // Ok
263+
~~~~~~
264+
!!! error TS2322: Type 'Record<string, MyObj[]>' is not assignable to type 'HelperCond<T, string, MyObj[], undefined, Record<string, MyObj[]>>'.
210265
}
211266
return /** @type {MessageBoxAction[]} */([]); // Ok
267+
~~~~~~
268+
!!! error TS2322: Type 'MyObj[]' is not assignable to type 'HelperCond<T, string, MyObj[], undefined, Record<string, MyObj[]>>'.
212269
}
213270

214271
// File: Rocket.Chat/apps/meteor/ee/server/lib/engagementDashboard/date.ts
@@ -230,13 +287,23 @@ file.js(185,9): error TS2322: Type 'Record<string, MyObj[]>' is not assignable t
230287
function transformDatesForAPI(start, end) {
231288
return end !== undefined ?
232289
{
290+
~
233291
start: mapDateForAPI(start),
292+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
234293
end: mapDateForAPI(end),
294+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
235295
} :
296+
~~~~~~~~~
297+
!!! error TS2322: Type '{ start: Date; end: Date; }' is not assignable to type 'HelperCond<T, string, { start: Date; end: Date; }, undefined, { start: Date; end: undefined; }>'.
236298
{
299+
~
237300
start: mapDateForAPI(start),
301+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
238302
end: undefined
303+
~~~~~~~~~~~~~~~~~~~~~~~~~~
239304
};
305+
~~~~~~~~~
306+
!!! error TS2322: Type '{ start: Date; end: undefined; }' is not assignable to type 'HelperCond<T, string, { start: Date; end: Date; }, undefined, { start: Date; end: undefined; }>'.
240307
}
241308

242309
// File: Rocket.Chat/packages/agenda/src/Agenda.ts
@@ -287,10 +354,15 @@ file.js(185,9): error TS2322: Type 'Record<string, MyObj[]>' is not assignable t
287354
async newEvery(interval, name, data, options) {
288355
if (typeof name === 'string') {
289356
return this._createIntervalJob(interval, name, data, options); // Ok
357+
~~~~~~
358+
!!! error TS2322: Type 'MyObj' is not assignable to type 'HelperCond<T, string, MyObj, string[], MyObj[] | undefined>'.
290359
}
291360

292361
if (Array.isArray(name)) {
293362
return this._createIntervalJobs(interval, name, data, options); // Ok
363+
~~~~~~
364+
!!! error TS2322: Type 'MyObj[] | undefined' is not assignable to type 'HelperCond<T, string, MyObj, string[], MyObj[] | undefined>'.
365+
!!! error TS2322: Type 'undefined' is not assignable to type 'HelperCond<T, string, MyObj, string[], MyObj[] | undefined>'.
294366
}
295367

296368
throw new Error('Unexpected error: Invalid job name(s)');
@@ -306,9 +378,13 @@ file.js(185,9): error TS2322: Type 'Record<string, MyObj[]>' is not assignable t
306378
*/
307379
function transform1(value) {
308380
if (value == null) return null; // Ok
381+
~~~~~~
382+
!!! error TS2322: Type 'null' is not assignable to type 'HelperCond<T, string, string, null | undefined, null>'.
309383
if (typeof value !== 'string') {
310384
throw new Error();
311385
}
312386
return value.toLowerCase(); // Ok
387+
~~~~~~
388+
!!! error TS2322: Type 'string' is not assignable to type 'HelperCond<T, string, string, null | undefined, null>'.
313389
}
314390

0 commit comments

Comments
 (0)