improved typesafety

This commit is contained in:
Daniel
2023-05-27 19:59:39 +03:30
parent a0a7ccc952
commit 36778810c5
11 changed files with 87 additions and 89 deletions
+7 -26
View File
@@ -5,35 +5,16 @@
import { Collection, Link, Tag, User } from "@prisma/client";
type OptionalExcluding<T, TRequired extends keyof T> = Partial<T> &
export type OptionalExcluding<T, TRequired extends keyof T> = Partial<T> &
Pick<T, TRequired>;
export interface ExtendedLink extends Link {
export interface LinkIncludingCollectionAndTags
extends Omit<Link, "id" | "createdAt" | "collectionId"> {
id?: number;
createdAt?: string;
collectionId?: number;
tags: Tag[];
collection: Collection;
}
export interface NewLink {
name: string;
url: string;
tags: Tag[];
collection: {
id: number | undefined;
name: string | undefined;
ownerId: number | undefined;
};
}
export interface NewCollection {
name: string;
description: string;
members: {
name: string;
email: string;
canCreate: boolean;
canUpdate: boolean;
canDelete: boolean;
}[];
collection: OptionalExcluding<Collection, "name" | "ownerId">;
}
export interface Member {