Skip to content

Commit 21c053c

Browse files
committed
Update .types tests
1 parent 4f13aa0 commit 21c053c

File tree

5 files changed

+147
-218
lines changed

5 files changed

+147
-218
lines changed

tests/baselines/reference/templateLiteralTypes4.errors.txt

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
tests/cases/conformance/types/literal/templateLiteralTypes4.ts(294,12): error TS2345: Argument of type '2' is not assignable to parameter of type '0 | 1'.
2-
tests/cases/conformance/types/literal/templateLiteralTypes4.ts(298,12): error TS2345: Argument of type '2' is not assignable to parameter of type '0 | 1'.
1+
tests/cases/conformance/types/literal/templateLiteralTypes4.ts(285,12): error TS2345: Argument of type '2' is not assignable to parameter of type '0 | 1'.
2+
tests/cases/conformance/types/literal/templateLiteralTypes4.ts(289,12): error TS2345: Argument of type '2' is not assignable to parameter of type '0 | 1'.
33

44

55
==== tests/cases/conformance/types/literal/templateLiteralTypes4.ts (2 errors) ====
@@ -230,19 +230,10 @@ tests/cases/conformance/types/literal/templateLiteralTypes4.ts(298,12): error TS
230230
| (T extends `${infer U extends boolean | null | undefined}` ? U : never)
231231
;
232232

233-
// .types tests here are worthless until #48578 is merged
234-
type Check<T, U extends T> = void;
235-
236233
type TExtract0 = ExtractPrimitives<"100">; // "100" | 100 | 100n
237234
type TExtract1 = ExtractPrimitives<"1.1">; // "1.1" | 1.1
238235
type TExtract2 = ExtractPrimitives<"true">; // "true" | true
239236

240-
type _ = [
241-
Check<TExtract0, "100" | 100 | 100n>,
242-
Check<TExtract1, "1.1" | 1.1>,
243-
Check<TExtract2, "true" | true>,
244-
];
245-
246237

247238

248239
// example use case (based on old TypedObjects proposal):

tests/baselines/reference/templateLiteralTypes4.js

-15
Original file line numberDiff line numberDiff line change
@@ -226,19 +226,10 @@ type ExtractPrimitives<T extends string> =
226226
| (T extends `${infer U extends boolean | null | undefined}` ? U : never)
227227
;
228228

229-
// .types tests here are worthless until #48578 is merged
230-
type Check<T, U extends T> = void;
231-
232229
type TExtract0 = ExtractPrimitives<"100">; // "100" | 100 | 100n
233230
type TExtract1 = ExtractPrimitives<"1.1">; // "1.1" | 1.1
234231
type TExtract2 = ExtractPrimitives<"true">; // "true" | true
235232

236-
type _ = [
237-
Check<TExtract0, "100" | 100 | 100n>,
238-
Check<TExtract1, "1.1" | 1.1>,
239-
Check<TExtract2, "true" | true>,
240-
];
241-
242233

243234

244235
// example use case (based on old TypedObjects proposal):
@@ -440,15 +431,9 @@ declare type TPrefix0 = "100" extends `${infer T extends number}${string}` ? T :
440431
declare type TPrefix1 = "trueabc" extends `${infer T extends boolean}${string}` ? T : never;
441432
declare type TPrefix2 = `100:${string}` extends `${infer T extends number}:${string}` ? T : never;
442433
declare type ExtractPrimitives<T extends string> = T | (T extends `${infer U extends number}` ? U : never) | (T extends `${infer U extends bigint}` ? U : never) | (T extends `${infer U extends boolean | null | undefined}` ? U : never);
443-
declare type Check<T, U extends T> = void;
444434
declare type TExtract0 = ExtractPrimitives<"100">;
445435
declare type TExtract1 = ExtractPrimitives<"1.1">;
446436
declare type TExtract2 = ExtractPrimitives<"true">;
447-
declare type _ = [
448-
Check<TExtract0, "100" | 100 | 100n>,
449-
Check<TExtract1, "1.1" | 1.1>,
450-
Check<TExtract2, "true" | true>
451-
];
452437
declare type IndexFor<S extends string> = S extends `${infer N extends number}` ? N : never;
453438
declare type IndicesOf<T> = IndexFor<Extract<keyof T, string>>;
454439
interface FieldDefinition {

0 commit comments

Comments
 (0)