Skip to content

Commit

Permalink
ts: Convert resolved_topic.js to TypeScript.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbansal1999 authored and timabbott committed May 1, 2023
1 parent 914ed51 commit aa33ae4
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export const RESOLVED_TOPIC_PREFIX = "✔ ";
// Compare maybe_send_resolve_topic_notifications in zerver/actions/message_edit.py.
const RESOLVED_TOPIC_PREFIX_RE = /^ [ ]*/;

export function is_resolved(topic_name) {
export function is_resolved(topic_name: string): boolean {
return topic_name.startsWith(RESOLVED_TOPIC_PREFIX);
}

export function resolve_name(topic_name) {
export function resolve_name(topic_name: string): string {
return RESOLVED_TOPIC_PREFIX + topic_name;
}

Expand All @@ -24,7 +24,7 @@ export function resolve_name(topic_name) {
*
* If the topic is already not a resolved topic, this is the identity.
*/
export function unresolve_name(topic_name) {
export function unresolve_name(topic_name: string): string {
return topic_name.replace(RESOLVED_TOPIC_PREFIX_RE, "");
}

Expand All @@ -38,7 +38,7 @@ export function unresolve_name(topic_name) {
* property we want when listing topics in the UI, so that we don't end up
* showing what look like several identical topics.
*/
export function display_parts(topic_name) {
export function display_parts(topic_name: string): [string, string] {
return is_resolved(topic_name)
? [RESOLVED_TOPIC_PREFIX, topic_name.slice(RESOLVED_TOPIC_PREFIX.length)]
: ["", topic_name];
Expand Down

0 comments on commit aa33ae4

Please sign in to comment.