Skip to content

Commit

Permalink
docs(examples): update generic types and inheritance constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalLytek committed Aug 3, 2020
1 parent c5a0676 commit 7ff22f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions examples/generic-types/paginated-response.type.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { ClassType, Field, ObjectType, Int } from "../../src";

export default function PaginatedResponse<TItem>(TItemClass: ClassType<TItem>) {
export default function PaginatedResponse<TItemsFieldValue>(
itemsFieldValue: ClassType<TItemsFieldValue> | String | Number | Boolean,
) {
// `isAbstract` decorator option is mandatory to prevent registering in schema
@ObjectType({ isAbstract: true })
abstract class PaginatedResponseClass {
@Field(type => [TItemClass])
items: TItem[];
@Field(type => [itemsFieldValue])
items: TItemsFieldValue[];

@Field(type => Int)
total: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class GetAllArgs {
}

export function ResourceResolver<TResource extends Resource>(
ResourceCls: ClassType,
ResourceCls: ClassType<TResource>,
resources: TResource[],
) {
const resourceName = ResourceCls.name.toLocaleLowerCase();
Expand Down

0 comments on commit 7ff22f6

Please sign in to comment.