Skip to content

Commit cb4fb92

Browse files
committed
enhance: Remove typing redundancy
1 parent daff307 commit cb4fb92

File tree

6 files changed

+26
-85
lines changed

6 files changed

+26
-85
lines changed

.changeset/odd-numbers-matter.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@data-client/endpoint': patch
3+
'@data-client/rest': patch
4+
---
5+
6+
Remove typing redundancy

packages/endpoint/src/schema.d.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -381,19 +381,6 @@ export class Values<Choices extends Schema = any> implements SchemaClass {
381381
): undefined;
382382
}
383383

384-
export type CollectionArrayAdder<S extends PolymorphicInterface> =
385-
S extends (
386-
{
387-
// ensure we are an array type
388-
denormalize(...args: any): any[];
389-
// get what we are an array of
390-
schema: infer T;
391-
}
392-
) ?
393-
// TODO: eventually we want to allow singular or list and infer the return based on arguments
394-
T
395-
: never;
396-
397384
export declare let CollectionRoot: CollectionConstructor;
398385

399386
/**

website/src/components/Playground/editor-types/@data-client/endpoint.d.ts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ type CollectionOptions<Args extends any[] = DefaultArgs, Parent = any> = ({
550550
nonFilterArgumentKeys?: ((key: string) => boolean) | string[] | RegExp;
551551
});
552552

553-
type CollectionArrayAdder$1<S extends PolymorphicInterface> = S extends ({
553+
type CollectionArrayAdder<S extends PolymorphicInterface> = S extends ({
554554
denormalize(...args: any): any[];
555555
schema: infer T;
556556
}) ? T : never;
@@ -628,11 +628,11 @@ interface CollectionInterface<S extends PolymorphicInterface = any, Args extends
628628
/** Schema to place at the *end* of this Collection
629629
* @see https://dataclient.io/rest/api/Collection#push
630630
*/
631-
push: CollectionArrayAdder$1<S>;
631+
push: CollectionArrayAdder<S>;
632632
/** Schema to place at the *beginning* of this Collection
633633
* @see https://dataclient.io/rest/api/Collection#unshift
634634
*/
635-
unshift: CollectionArrayAdder$1<S>;
635+
unshift: CollectionArrayAdder<S>;
636636
/** Schema to merge with a Values Collection
637637
* @see https://dataclient.io/rest/api/Collection#assign
638638
*/
@@ -997,19 +997,6 @@ declare class Values<Choices extends Schema = any> implements SchemaClass {
997997
): undefined;
998998
}
999999

1000-
type CollectionArrayAdder<S extends PolymorphicInterface> =
1001-
S extends (
1002-
{
1003-
// ensure we are an array type
1004-
denormalize(...args: any): any[];
1005-
// get what we are an array of
1006-
schema: infer T;
1007-
}
1008-
) ?
1009-
// TODO: eventually we want to allow singular or list and infer the return based on arguments
1010-
T
1011-
: never;
1012-
10131000
declare let CollectionRoot: CollectionConstructor;
10141001

10151002
/**
@@ -1046,11 +1033,11 @@ type schema_d_Union<Choices extends EntityMap, SchemaAttribute extends
10461033
declare const schema_d_Union: typeof Union;
10471034
type schema_d_Values<Choices extends Schema = any> = Values<Choices>;
10481035
declare const schema_d_Values: typeof Values;
1049-
type schema_d_CollectionArrayAdder<S extends PolymorphicInterface> = CollectionArrayAdder<S>;
10501036
declare const schema_d_CollectionRoot: typeof CollectionRoot;
10511037
type schema_d_Collection<S extends any[] | PolymorphicInterface = any, Args extends any[] = DefaultArgs, Parent = any> = Collection<S, Args, Parent>;
10521038
declare const schema_d_Collection: typeof Collection;
10531039
type schema_d_EntityInterface<T = any> = EntityInterface<T>;
1040+
type schema_d_CollectionArrayAdder<S extends PolymorphicInterface> = CollectionArrayAdder<S>;
10541041
type schema_d_CollectionInterface<S extends PolymorphicInterface = any, Args extends any[] = any[], Parent = any> = CollectionInterface<S, Args, Parent>;
10551042
type schema_d_CollectionFromSchema<S extends any[] | PolymorphicInterface = any, Args extends any[] = DefaultArgs, Parent = any> = CollectionFromSchema<S, Args, Parent>;
10561043
type schema_d_CollectionConstructor = CollectionConstructor;
@@ -1076,10 +1063,10 @@ declare namespace schema_d {
10761063
schema_d_UnionRoot as UnionRoot,
10771064
schema_d_Union as Union,
10781065
schema_d_Values as Values,
1079-
schema_d_CollectionArrayAdder as CollectionArrayAdder,
10801066
schema_d_CollectionRoot as CollectionRoot,
10811067
schema_d_Collection as Collection,
10821068
schema_d_EntityInterface as EntityInterface,
1069+
schema_d_CollectionArrayAdder as CollectionArrayAdder,
10831070
schema_d_CollectionInterface as CollectionInterface,
10841071
schema_d_CollectionFromSchema as CollectionFromSchema,
10851072
schema_d_CollectionConstructor as CollectionConstructor,

website/src/components/Playground/editor-types/@data-client/graphql.d.ts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ type CollectionOptions<Args extends any[] = DefaultArgs, Parent = any> = ({
550550
nonFilterArgumentKeys?: ((key: string) => boolean) | string[] | RegExp;
551551
});
552552

553-
type CollectionArrayAdder$1<S extends PolymorphicInterface> = S extends ({
553+
type CollectionArrayAdder<S extends PolymorphicInterface> = S extends ({
554554
denormalize(...args: any): any[];
555555
schema: infer T;
556556
}) ? T : never;
@@ -628,11 +628,11 @@ interface CollectionInterface<S extends PolymorphicInterface = any, Args extends
628628
/** Schema to place at the *end* of this Collection
629629
* @see https://dataclient.io/rest/api/Collection#push
630630
*/
631-
push: CollectionArrayAdder$1<S>;
631+
push: CollectionArrayAdder<S>;
632632
/** Schema to place at the *beginning* of this Collection
633633
* @see https://dataclient.io/rest/api/Collection#unshift
634634
*/
635-
unshift: CollectionArrayAdder$1<S>;
635+
unshift: CollectionArrayAdder<S>;
636636
/** Schema to merge with a Values Collection
637637
* @see https://dataclient.io/rest/api/Collection#assign
638638
*/
@@ -997,19 +997,6 @@ declare class Values<Choices extends Schema = any> implements SchemaClass {
997997
): undefined;
998998
}
999999

1000-
type CollectionArrayAdder<S extends PolymorphicInterface> =
1001-
S extends (
1002-
{
1003-
// ensure we are an array type
1004-
denormalize(...args: any): any[];
1005-
// get what we are an array of
1006-
schema: infer T;
1007-
}
1008-
) ?
1009-
// TODO: eventually we want to allow singular or list and infer the return based on arguments
1010-
T
1011-
: never;
1012-
10131000
declare let CollectionRoot: CollectionConstructor;
10141001

10151002
/**
@@ -1046,11 +1033,11 @@ type schema_d_Union<Choices extends EntityMap, SchemaAttribute extends
10461033
declare const schema_d_Union: typeof Union;
10471034
type schema_d_Values<Choices extends Schema = any> = Values<Choices>;
10481035
declare const schema_d_Values: typeof Values;
1049-
type schema_d_CollectionArrayAdder<S extends PolymorphicInterface> = CollectionArrayAdder<S>;
10501036
declare const schema_d_CollectionRoot: typeof CollectionRoot;
10511037
type schema_d_Collection<S extends any[] | PolymorphicInterface = any, Args extends any[] = DefaultArgs, Parent = any> = Collection<S, Args, Parent>;
10521038
declare const schema_d_Collection: typeof Collection;
10531039
type schema_d_EntityInterface<T = any> = EntityInterface<T>;
1040+
type schema_d_CollectionArrayAdder<S extends PolymorphicInterface> = CollectionArrayAdder<S>;
10541041
type schema_d_CollectionInterface<S extends PolymorphicInterface = any, Args extends any[] = any[], Parent = any> = CollectionInterface<S, Args, Parent>;
10551042
type schema_d_CollectionFromSchema<S extends any[] | PolymorphicInterface = any, Args extends any[] = DefaultArgs, Parent = any> = CollectionFromSchema<S, Args, Parent>;
10561043
type schema_d_CollectionConstructor = CollectionConstructor;
@@ -1076,10 +1063,10 @@ declare namespace schema_d {
10761063
schema_d_UnionRoot as UnionRoot,
10771064
schema_d_Union as Union,
10781065
schema_d_Values as Values,
1079-
schema_d_CollectionArrayAdder as CollectionArrayAdder,
10801066
schema_d_CollectionRoot as CollectionRoot,
10811067
schema_d_Collection as Collection,
10821068
schema_d_EntityInterface as EntityInterface,
1069+
schema_d_CollectionArrayAdder as CollectionArrayAdder,
10831070
schema_d_CollectionInterface as CollectionInterface,
10841071
schema_d_CollectionFromSchema as CollectionFromSchema,
10851072
schema_d_CollectionConstructor as CollectionConstructor,

website/src/components/Playground/editor-types/@data-client/rest.d.ts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ type CollectionOptions<Args extends any[] = DefaultArgs, Parent = any> = ({
548548
nonFilterArgumentKeys?: ((key: string) => boolean) | string[] | RegExp;
549549
});
550550

551-
type CollectionArrayAdder$1<S extends PolymorphicInterface> = S extends ({
551+
type CollectionArrayAdder<S extends PolymorphicInterface> = S extends ({
552552
denormalize(...args: any): any[];
553553
schema: infer T;
554554
}) ? T : never;
@@ -626,11 +626,11 @@ interface CollectionInterface<S extends PolymorphicInterface = any, Args extends
626626
/** Schema to place at the *end* of this Collection
627627
* @see https://dataclient.io/rest/api/Collection#push
628628
*/
629-
push: CollectionArrayAdder$1<S>;
629+
push: CollectionArrayAdder<S>;
630630
/** Schema to place at the *beginning* of this Collection
631631
* @see https://dataclient.io/rest/api/Collection#unshift
632632
*/
633-
unshift: CollectionArrayAdder$1<S>;
633+
unshift: CollectionArrayAdder<S>;
634634
/** Schema to merge with a Values Collection
635635
* @see https://dataclient.io/rest/api/Collection#assign
636636
*/
@@ -995,19 +995,6 @@ declare class Values<Choices extends Schema = any> implements SchemaClass {
995995
): undefined;
996996
}
997997

998-
type CollectionArrayAdder<S extends PolymorphicInterface> =
999-
S extends (
1000-
{
1001-
// ensure we are an array type
1002-
denormalize(...args: any): any[];
1003-
// get what we are an array of
1004-
schema: infer T;
1005-
}
1006-
) ?
1007-
// TODO: eventually we want to allow singular or list and infer the return based on arguments
1008-
T
1009-
: never;
1010-
1011998
declare let CollectionRoot: CollectionConstructor;
1012999

10131000
/**
@@ -1044,11 +1031,11 @@ type schema_d_Union<Choices extends EntityMap, SchemaAttribute extends
10441031
declare const schema_d_Union: typeof Union;
10451032
type schema_d_Values<Choices extends Schema = any> = Values<Choices>;
10461033
declare const schema_d_Values: typeof Values;
1047-
type schema_d_CollectionArrayAdder<S extends PolymorphicInterface> = CollectionArrayAdder<S>;
10481034
declare const schema_d_CollectionRoot: typeof CollectionRoot;
10491035
type schema_d_Collection<S extends any[] | PolymorphicInterface = any, Args extends any[] = DefaultArgs, Parent = any> = Collection<S, Args, Parent>;
10501036
declare const schema_d_Collection: typeof Collection;
10511037
type schema_d_EntityInterface<T = any> = EntityInterface<T>;
1038+
type schema_d_CollectionArrayAdder<S extends PolymorphicInterface> = CollectionArrayAdder<S>;
10521039
type schema_d_CollectionInterface<S extends PolymorphicInterface = any, Args extends any[] = any[], Parent = any> = CollectionInterface<S, Args, Parent>;
10531040
type schema_d_CollectionFromSchema<S extends any[] | PolymorphicInterface = any, Args extends any[] = DefaultArgs, Parent = any> = CollectionFromSchema<S, Args, Parent>;
10541041
type schema_d_CollectionConstructor = CollectionConstructor;
@@ -1074,10 +1061,10 @@ declare namespace schema_d {
10741061
schema_d_UnionRoot as UnionRoot,
10751062
schema_d_Union as Union,
10761063
schema_d_Values as Values,
1077-
schema_d_CollectionArrayAdder as CollectionArrayAdder,
10781064
schema_d_CollectionRoot as CollectionRoot,
10791065
schema_d_Collection as Collection,
10801066
schema_d_EntityInterface as EntityInterface,
1067+
schema_d_CollectionArrayAdder as CollectionArrayAdder,
10811068
schema_d_CollectionInterface as CollectionInterface,
10821069
schema_d_CollectionFromSchema as CollectionFromSchema,
10831070
schema_d_CollectionConstructor as CollectionConstructor,

website/src/components/Playground/editor-types/globals.d.ts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ type CollectionOptions<Args extends any[] = DefaultArgs, Parent = any> = ({
552552
nonFilterArgumentKeys?: ((key: string) => boolean) | string[] | RegExp;
553553
});
554554

555-
type CollectionArrayAdder$1<S extends PolymorphicInterface> = S extends ({
555+
type CollectionArrayAdder<S extends PolymorphicInterface> = S extends ({
556556
denormalize(...args: any): any[];
557557
schema: infer T;
558558
}) ? T : never;
@@ -630,11 +630,11 @@ interface CollectionInterface<S extends PolymorphicInterface = any, Args extends
630630
/** Schema to place at the *end* of this Collection
631631
* @see https://dataclient.io/rest/api/Collection#push
632632
*/
633-
push: CollectionArrayAdder$1<S>;
633+
push: CollectionArrayAdder<S>;
634634
/** Schema to place at the *beginning* of this Collection
635635
* @see https://dataclient.io/rest/api/Collection#unshift
636636
*/
637-
unshift: CollectionArrayAdder$1<S>;
637+
unshift: CollectionArrayAdder<S>;
638638
/** Schema to merge with a Values Collection
639639
* @see https://dataclient.io/rest/api/Collection#assign
640640
*/
@@ -999,19 +999,6 @@ declare class Values<Choices extends Schema = any> implements SchemaClass {
999999
): undefined;
10001000
}
10011001

1002-
type CollectionArrayAdder<S extends PolymorphicInterface> =
1003-
S extends (
1004-
{
1005-
// ensure we are an array type
1006-
denormalize(...args: any): any[];
1007-
// get what we are an array of
1008-
schema: infer T;
1009-
}
1010-
) ?
1011-
// TODO: eventually we want to allow singular or list and infer the return based on arguments
1012-
T
1013-
: never;
1014-
10151002
declare let CollectionRoot: CollectionConstructor;
10161003

10171004
/**
@@ -1048,11 +1035,11 @@ type schema_d_Union<Choices extends EntityMap, SchemaAttribute extends
10481035
declare const schema_d_Union: typeof Union;
10491036
type schema_d_Values<Choices extends Schema = any> = Values<Choices>;
10501037
declare const schema_d_Values: typeof Values;
1051-
type schema_d_CollectionArrayAdder<S extends PolymorphicInterface> = CollectionArrayAdder<S>;
10521038
declare const schema_d_CollectionRoot: typeof CollectionRoot;
10531039
type schema_d_Collection<S extends any[] | PolymorphicInterface = any, Args extends any[] = DefaultArgs, Parent = any> = Collection<S, Args, Parent>;
10541040
declare const schema_d_Collection: typeof Collection;
10551041
type schema_d_EntityInterface<T = any> = EntityInterface<T>;
1042+
type schema_d_CollectionArrayAdder<S extends PolymorphicInterface> = CollectionArrayAdder<S>;
10561043
type schema_d_CollectionInterface<S extends PolymorphicInterface = any, Args extends any[] = any[], Parent = any> = CollectionInterface<S, Args, Parent>;
10571044
type schema_d_CollectionFromSchema<S extends any[] | PolymorphicInterface = any, Args extends any[] = DefaultArgs, Parent = any> = CollectionFromSchema<S, Args, Parent>;
10581045
type schema_d_CollectionConstructor = CollectionConstructor;
@@ -1078,10 +1065,10 @@ declare namespace schema_d {
10781065
schema_d_UnionRoot as UnionRoot,
10791066
schema_d_Union as Union,
10801067
schema_d_Values as Values,
1081-
schema_d_CollectionArrayAdder as CollectionArrayAdder,
10821068
schema_d_CollectionRoot as CollectionRoot,
10831069
schema_d_Collection as Collection,
10841070
schema_d_EntityInterface as EntityInterface,
1071+
schema_d_CollectionArrayAdder as CollectionArrayAdder,
10851072
schema_d_CollectionInterface as CollectionInterface,
10861073
schema_d_CollectionFromSchema as CollectionFromSchema,
10871074
schema_d_CollectionConstructor as CollectionConstructor,

0 commit comments

Comments
 (0)