From: Ruben Beltran del Rio Date: Sun, 1 May 2022 13:01:31 +0000 (+0200) Subject: Add type definitions X-Git-Url: https://git.r.bdr.sh/rbdr/forum/commitdiff_plain/d197e31bf0437889f792e013df32b868fffc35d9?ds=sidebyside Add type definitions --- diff --git a/src/lib/data/types.d.ts b/src/lib/data/types.d.ts new file mode 100644 index 0000000..2498bf7 --- /dev/null +++ b/src/lib/data/types.d.ts @@ -0,0 +1,42 @@ +/* + * These types are the structures that we can expect + * from the API. + */ + +export type Topic = { + id: string; + title: string; + ttl: number; + updated_at: number; + tags: Tag[]; + posts: Post[]; + forum: Forum; +}; + +export type Post = { + id: string; + created_at: number; + title: string; + text: string; + topic: Topic; + author: Author; +}; + +export type Tag = { + id: string; + weight: number; + topics: Topic[]; +}; + +export type Forum = { + id: string; + glyph: string; + label: string; + position: number; + topics: Topic[]; +}; + +export type Author = { + id: string; + handle: string; +}; diff --git a/src/lib/data/vendor.d.ts b/src/lib/data/vendor.d.ts new file mode 100644 index 0000000..98e2d46 --- /dev/null +++ b/src/lib/data/vendor.d.ts @@ -0,0 +1,15 @@ +declare module 'language-name-map' { + export type LanguageNameMap = { + [languageCode: string]: LanguageName; + }; + + export type LanguageName = { + name: string; + native: string; + dir: 'rtl' | 'ltr'; + }; + + export function getLangNameFromCode(langCode: string): LanguageName; + export function getLangCodeList(): string[]; + export const languageNameMap: LanguageNameMap; +}