diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2022-05-01 15:01:31 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2022-05-01 15:01:31 +0200 |
| commit | d197e31bf0437889f792e013df32b868fffc35d9 (patch) | |
| tree | b774a2ad538c3eafc16c6005aa34c76db0933977 /src/lib | |
| parent | 377653d56eb7af7498ceebc224d6bc45f32f0ae0 (diff) | |
Add type definitions
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/data/types.d.ts | 42 | ||||
| -rw-r--r-- | src/lib/data/vendor.d.ts | 15 |
2 files changed, 57 insertions, 0 deletions
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; +} |