From d197e31bf0437889f792e013df32b868fffc35d9 Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Sun, 1 May 2022 15:01:31 +0200 Subject: Add type definitions --- src/lib/data/types.d.ts | 42 ++++++++++++++++++++++++++++++++++++++++++ src/lib/data/vendor.d.ts | 15 +++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 src/lib/data/types.d.ts create mode 100644 src/lib/data/vendor.d.ts (limited to 'src/lib') 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; +} -- cgit