Skip to content

Commit b166733

Browse files
authored
Merge pull request #108 from andnp/Fix-KeysByType
Fix keys by type
2 parents 92a9ca8 + 5905cf5 commit b166733

File tree

4 files changed

+50
-62
lines changed

4 files changed

+50
-62
lines changed

README.md

-51
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ test('Can get all keys between objects', t => {
6666
assert<got, expected>(t);
6767
assert<expected, got>(t);
6868
});
69-
7069
```
7170

7271
### AllRequired
@@ -80,7 +79,6 @@ test('Can make all fields of options object required (not optional and not nulla
8079
assert<got, expected>(t);
8180
assert<expected, got>(t);
8281
});
83-
8482
```
8583

8684
### CombineObjects
@@ -102,7 +100,6 @@ test('Can combine two objects (without pesky & in vscode)', t => {
102100
assert<got, expected>(t);
103101
assert<expected, got>(t);
104102
});
105-
106103
```
107104

108105
### DeepPartial
@@ -169,7 +166,6 @@ test('Can get a deep partial object with functions', t => {
169166
assert<got, expected>(t);
170167
assert<expected, got>(t);
171168
});
172-
173169
```
174170

175171
### DeepReadonly
@@ -216,7 +212,6 @@ test('Can make an object with functions readonly', t => {
216212
assert<got, expected>(t);
217213
assert<expected, got>(t);
218214
});
219-
220215
```
221216

222217
### DiffKeys
@@ -234,7 +229,6 @@ test('Can get all keys that are different between objects', t => {
234229
assert<gotA, 'x'>(t);
235230
assert<gotB, 'z'>(t);
236231
});
237-
238232
```
239233

240234
### GetKey
@@ -259,7 +253,6 @@ test('Will get `never` if key does not exist', t => {
259253
assert<got, expected>(t);
260254
assert<expected, got>(t);
261255
});
262-
263256
```
264257

265258
### HasKey
@@ -280,7 +273,6 @@ test('Can get an object with only shared properties', t => {
280273
assert<got, expected>(t);
281274
assert<expected, got>(t);
282275
});
283-
284276
```
285277

286278
### KeysByType
@@ -299,7 +291,6 @@ test('Can filter object keys by right side type', t => {
299291
assert<got, expected>(t);
300292
assert<expected, got>(t);
301293
});
302-
303294
```
304295

305296
### Merge
@@ -329,7 +320,6 @@ test('Can merge an object containing all strings as keys', t => {
329320
assert<got, expected>(t);
330321
assert<expected, got>(t);
331322
});
332-
333323
```
334324

335325
### ObjectKeys
@@ -353,7 +343,6 @@ test('Can turn an object into another object', t => {
353343
assert<got, expected>(t);
354344
assert<expected, got>(t);
355345
});
356-
357346
```
358347

359348
### Omit
@@ -369,7 +358,6 @@ test('Can omit keys from an object', t => {
369358
assert<got, expected>(t);
370359
assert<expected, got>(t);
371360
});
372-
373361
```
374362

375363
### Optional
@@ -384,7 +372,6 @@ test('Can make properties optional', t => {
384372
assert<got, expected>(t);
385373
assert<expected, got>(t);
386374
});
387-
388375
```
389376

390377
### Overwrite
@@ -403,7 +390,6 @@ test('Can overwrite properties on an object', t => {
403390
assert<got2, expected>(t);
404391
assert<expected, got2>(t);
405392
});
406-
407393
```
408394

409395
### PlainObject
@@ -433,7 +419,6 @@ test('Can make certain fields of options object required', t => {
433419
assert<got2, expected2>(t);
434420
assert<got3, expected3>(t);
435421
});
436-
437422
```
438423

439424
### SharedKeys
@@ -449,7 +434,6 @@ test('Can get keys that are same between objects', t => {
449434
assert<got, expected>(t);
450435
assert<expected, got>(t);
451436
});
452-
453437
```
454438

455439
### StrictUnion
@@ -474,7 +458,6 @@ test('disallow union members with mixed properties', t => {
474458
assert<isStrict<nonStrictUnion>, 'No'>(t);
475459

476460
});
477-
478461
```
479462

480463
### StringKeys
@@ -500,7 +483,6 @@ test('Can get a union of all values in an object', t => {
500483
assert<got, expected>(t);
501484
assert<expected, got>(t);
502485
});
503-
504486
```
505487

506488
### UnionKeys
@@ -517,7 +499,6 @@ test('Can get all keys between objects in a union', t => {
517499
assert<got, expected>(t);
518500
assert<expected, got>(t);
519501
});
520-
521502
```
522503

523504
## Utils
@@ -557,7 +538,6 @@ test("cannot be used to prevent a distributive conditional from distributing", t
557538
assert<Test, "Yes" | "No">(t);
558539
assert<"Yes" | "No", Test>(t);
559540
});
560-
561541
```
562542

563543
### NoInfer
@@ -573,7 +553,6 @@ test('Will not infer based on second argument', t => {
573553
assert<typeof x, 'hi'>(t);
574554
assert<typeof x, number>(t);
575555
});
576-
577556
```
578557

579558
### Nominal
@@ -586,7 +565,6 @@ test('Can make a new nominal type', t => {
586565
// TODO: improve once negative testing is in place
587566
assert<Id, Nominal<string, 'id'>>(t);
588567
});
589-
590568
```
591569

592570
### Nullable
@@ -604,7 +582,6 @@ test('Will make a type not nullable', t => {
604582

605583
assert<got, string>(t);
606584
});
607-
608585
```
609586

610587
### PromiseOr
@@ -616,7 +593,6 @@ test('Will give back a promise containing given type union the type itself', t =
616593

617594
assert<got, expected>(t);
618595
});
619-
620596
```
621597

622598
### UnionToIntersection
@@ -640,7 +616,6 @@ test('Union of Objects', t => {
640616

641617
assert<got, expected>(t);
642618
});
643-
644619
```
645620

646621
## Functions
@@ -659,7 +634,6 @@ test('Can define the type of a function that takes any arguments', t => {
659634
assert<got, expected>(t);
660635
assert<got2, expected2>(t);
661636
});
662-
663637
```
664638

665639
### ArgsAsTuple
@@ -681,7 +655,6 @@ test("Can get a tuple of function's argument types", t => {
681655
assert<ArgsAsTuple<F2>, E2>(t);
682656
assert<ArgsAsTuple<F3>, E3>(t);
683657
});
684-
685658
```
686659

687660
### ConstructorFunction
@@ -693,7 +666,6 @@ test('Can build a constructor type for a type', t => {
693666

694667
assert<Constructor, typeof Thing>(t);
695668
});
696-
697669
```
698670

699671
### OverwriteReturn
@@ -708,8 +680,6 @@ test('Can change return type of a function', t => {
708680
assert<got, expected>(t);
709681
assert<expected, got>(t);
710682
});
711-
712-
713683
```
714684

715685
### Predicate
@@ -721,7 +691,6 @@ test('Can build a predicate function with single known argument type', t => {
721691

722692
assert<PredFunc, expected>(t);
723693
});
724-
725694
```
726695

727696
## Strings
@@ -737,7 +706,6 @@ test('Can remove a string from a union of strings', t => {
737706
assert<DropString<b, 'hey' | 'there'>, never>(t);
738707
assert<DropString<a, 'hi' | 'there'>, never>(t);
739708
});
740-
741709
```
742710

743711
### StringEqual
@@ -752,7 +720,6 @@ test('Can check that two unions of strings are equal', t => {
752720
assert<StringEqual<b, a>, True>(t);
753721
assert<StringEqual<b, c>, False>(t);
754722
});
755-
756723
```
757724

758725
### UnionContains
@@ -773,7 +740,6 @@ test('Can get the intersection of tuple values', t => {
773740
assert<got, expected>(t);
774741
assert<expected, got>(t);
775742
});
776-
777743
```
778744

779745
### Length
@@ -789,7 +755,6 @@ test('Can get the length of a tuple', t => {
789755
assert<gotX, 2>(t);
790756
assert<gotT, 4>(t);
791757
});
792-
793758
```
794759

795760
### UnionizeTuple
@@ -804,7 +769,6 @@ test('Can get a union of all values in tuple', t => {
804769
assert<got, expected>(t);
805770
assert<expected, got>(t);
806771
});
807-
808772
```
809773

810774
## Numbers
@@ -816,7 +780,6 @@ test('Can add two numbers', t => {
816780
type fifty = Add<12, 38>;
817781
assert<fifty, 50>(t);
818782
});
819-
820783
```
821784

822785
### IsOne
@@ -828,7 +791,6 @@ test('Can check if a number is one', t => {
828791
assert<notOne, False>(t);
829792
assert<one, True>(t);
830793
});
831-
832794
```
833795

834796
### IsZero
@@ -840,7 +802,6 @@ test('Can check if a number is zero', t => {
840802
assert<notZero, False>(t);
841803
assert<zero, True>(t);
842804
});
843-
844805
```
845806

846807
### Next
@@ -856,7 +817,6 @@ test('Can check if two numbers are equal', t => {
856817
assert<notEqual, False>(t);
857818
assert<equal, True>(t);
858819
});
859-
860820
```
861821

862822
### Numbers
@@ -870,7 +830,6 @@ test('Can get a number as a string', t => {
870830
type str = NumberToString<22>;
871831
assert<str, '22'>(t);
872832
});
873-
874833
```
875834

876835
### Prev
@@ -884,7 +843,6 @@ test('Can subtract two numbers', t => {
884843
type ten = Sub<22, 12>;
885844
assert<ten, 10>(t);
886845
});
887-
888846
```
889847

890848
## Conditionals
@@ -904,7 +862,6 @@ test('Conditions can be based on AND', t => {
904862
assert<gotTF, string>(t);
905863
assert<gotTT, number>(t);
906864
});
907-
908865
```
909866

910867
### If
@@ -918,7 +875,6 @@ test('Can assign type conditionally', t => {
918875
assert<gotF, string>(t);
919876
assert<gotT, number>(t);
920877
});
921-
922878
```
923879

924880
### Nand
@@ -930,7 +886,6 @@ test('Conditions can be based on NAND', t => {
930886
assert<Nand<True, False>, True>(t);
931887
assert<Nand<False, False>, True>(t);
932888
});
933-
934889
```
935890

936891
### Not
@@ -944,7 +899,6 @@ test('Conditional logic can be inversed with NOT', t => {
944899
assert<gotF, number>(t);
945900
assert<gotT, string>(t);
946901
});
947-
948902
```
949903

950904
### Or
@@ -962,7 +916,6 @@ test('Conditions can be based on OR', t => {
962916
assert<gotTF, number>(t);
963917
assert<gotTT, number>(t);
964918
});
965-
966919
```
967920

968921
### Xor
@@ -974,7 +927,6 @@ test('Conditions can be based on XOR', t => {
974927
assert<Xor<True, False>, True>(t);
975928
assert<Xor<False, False>, False>(t);
976929
});
977-
978930
```
979931

980932
## Predicates
@@ -1049,7 +1001,6 @@ test('Can check if an object contains a key', t => {
10491001
t.fail();
10501002
}
10511003
});
1052-
10531004
```
10541005

10551006
### objectKeys
@@ -1067,7 +1018,6 @@ test('Can get keys of an object', t => {
10671018

10681019
t.deepEqual(keys, ['a', 'b']);
10691020
});
1070-
10711021
```
10721022

10731023
### Readonly
@@ -1098,6 +1048,5 @@ test('Can generate a tagged object', t => {
10981048
assert<typeof expected, typeof got>(t);
10991049

11001050
});
1101-
11021051
```
11031052

0 commit comments

Comments
 (0)