From 97ff25950679de8431c0f3dfd87f3ecce724767a Mon Sep 17 00:00:00 2001 From: nzai Date: Tue, 28 Mar 2023 22:47:19 +0300 Subject: [PATCH] ts: Migrate narrow_error to TypeScript. This commit migrates narrow_error.js to TypeScript by inferring the required types in the file and defining types in types.ts. --- web/src/narrow_error.js | 10 ---------- web/src/narrow_error.ts | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 10 deletions(-) delete mode 100644 web/src/narrow_error.js create mode 100644 web/src/narrow_error.ts diff --git a/web/src/narrow_error.js b/web/src/narrow_error.js deleted file mode 100644 index f26d33badf..0000000000 --- a/web/src/narrow_error.js +++ /dev/null @@ -1,10 +0,0 @@ -import render_empty_feed_notice from "../templates/empty_feed_notice.hbs"; - -export function narrow_error(narrow_banner_data) { - const title = narrow_banner_data.title; - const html = narrow_banner_data.html; - const search_data = narrow_banner_data.search_data; - - const empty_feed_notice = render_empty_feed_notice({title, html, search_data}); - return empty_feed_notice; -} diff --git a/web/src/narrow_error.ts b/web/src/narrow_error.ts new file mode 100644 index 0000000000..286fbd4197 --- /dev/null +++ b/web/src/narrow_error.ts @@ -0,0 +1,28 @@ +import render_empty_feed_notice from "../templates/empty_feed_notice.hbs"; + +type QueryWord = { + query_word: string; + is_stop_word: boolean; +}; + +type SearchData = { + query_word: QueryWord[]; + has_stop_word: boolean; + stream_query?: string; + topic_query?: string; +}; + +type NarrowBannerData = { + title: string; + html?: string; + search_data?: SearchData; +}; + +export function narrow_error(narrow_banner_data: NarrowBannerData): string { + const title = narrow_banner_data.title; + const html = narrow_banner_data.html; + const search_data = narrow_banner_data.search_data; + + const empty_feed_notice = render_empty_feed_notice({title, html, search_data}); + return empty_feed_notice; +}