From a6125c1579f70106f5dfedffb77dcc8f6dda6f30 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 23 Oct 2023 16:34:45 +0200 Subject: [PATCH] Migrate typing util to TypeScript --- src/util/{typing.js => typing.ts} | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) rename src/util/{typing.js => typing.ts} (57%) diff --git a/src/util/typing.js b/src/util/typing.ts similarity index 57% rename from src/util/typing.js rename to src/util/typing.ts index b471ae285..ed182557f 100644 --- a/src/util/typing.js +++ b/src/util/typing.ts @@ -1,7 +1,4 @@ -/** - * @template T - * @typedef {import('preact').Ref} Ref - */ +import type { Ref } from 'preact'; /** * Helper for downcasting a ref to a more specific type, where that is safe @@ -10,12 +7,7 @@ * This is mainly useful to cast a generic `Ref` to a more specific * element type (eg. `Ref`) for use with the `ref` prop of a JSX element. * Since Preact only writes to the `ref` prop, such a cast is safe. - * - * @template T - * @template {T} U - * @param {Ref|undefined} ref - * @return {Ref|undefined} */ -export function downcastRef(ref) { - return /** @type {Ref|undefined} */ (ref); +export function downcastRef(ref: Ref | undefined): Ref | undefined { + return ref as Ref | undefined; }