From c1f0d4ab9ab597cfd2f20ac275cf3fa22b71491d Mon Sep 17 00:00:00 2001 From: squidfunk Date: Sun, 2 Feb 2020 16:33:09 +0100 Subject: [PATCH] Improved JSX factory typings --- src/assets/javascripts/extensions/jsx/index.ts | 16 ++++------------ src/assets/javascripts/index.ts | 10 ---------- .../templates/search/result/_/index.tsx | 4 ++-- .../templates/search/result/article/index.tsx | 4 ++-- .../templates/search/result/section/index.tsx | 4 ++-- .../javascripts/templates/source/index.tsx | 4 ++-- 6 files changed, 12 insertions(+), 30 deletions(-) diff --git a/src/assets/javascripts/extensions/jsx/index.ts b/src/assets/javascripts/extensions/jsx/index.ts index 5af9143b0..2c46ef323 100644 --- a/src/assets/javascripts/extensions/jsx/index.ts +++ b/src/assets/javascripts/extensions/jsx/index.ts @@ -102,21 +102,13 @@ export function h( return el } -/** - * JSX factory wrapper - * - * @param el - JSX element - * - * @return HTML element - */ -export function toHTMLElement(el: JSXInternal.Element): HTMLElement { - return el as any // Hack: if you have a better idea, PR! -} - /* ---------------------------------------------------------------------------- * Namespace * ------------------------------------------------------------------------- */ export declare namespace h { - export import JSX = JSXInternal + namespace JSX { + type Element = HTMLElement + type IntrinsicElements = JSXInternal.IntrinsicElements + } } diff --git a/src/assets/javascripts/index.ts b/src/assets/javascripts/index.ts index 2b8659535..58047b31f 100644 --- a/src/assets/javascripts/index.ts +++ b/src/assets/javascripts/index.ts @@ -473,16 +473,6 @@ export function initialize(config: unknown) { filter(ev => !(ev.metaKey || ev.ctrlKey)) ) - // search mode is active! - key$.pipe( - takeIf(searchActive$) - // switchMapIf(searchActive$, x => { - // console.log("search mode!", x) - // return EMPTY - // }) - ) - .subscribe(x => console.log("search mode", x)) - // filter arrow keys if search is active! searchActive$.subscribe(console.log) diff --git a/src/assets/javascripts/templates/search/result/_/index.tsx b/src/assets/javascripts/templates/search/result/_/index.tsx index 82259c170..5de42b277 100644 --- a/src/assets/javascripts/templates/search/result/_/index.tsx +++ b/src/assets/javascripts/templates/search/result/_/index.tsx @@ -20,7 +20,7 @@ * IN THE SOFTWARE. */ -import { h, toHTMLElement } from "extensions" +import { h } from "extensions" import { SearchResult } from "modules" import { renderArticleDocument } from "../article" @@ -51,7 +51,7 @@ const css = { export function renderSearchResult( { article, sections }: SearchResult ): HTMLElement { - return toHTMLElement( + return (
  • {renderArticleDocument(article)} {...sections.map(renderSectionDocument)} diff --git a/src/assets/javascripts/templates/search/result/article/index.tsx b/src/assets/javascripts/templates/search/result/article/index.tsx index d6dd375da..8db5400da 100644 --- a/src/assets/javascripts/templates/search/result/article/index.tsx +++ b/src/assets/javascripts/templates/search/result/article/index.tsx @@ -20,7 +20,7 @@ * IN THE SOFTWARE. */ -import { h, toHTMLElement } from "extensions" +import { h } from "extensions" import { ArticleDocument } from "modules" import { truncate } from "utilities" @@ -52,7 +52,7 @@ const css = { export function renderArticleDocument( { location, title, text }: ArticleDocument ): HTMLElement { - return toHTMLElement( + return (

    {title}

    diff --git a/src/assets/javascripts/templates/search/result/section/index.tsx b/src/assets/javascripts/templates/search/result/section/index.tsx index 706b56ff7..aae24fc33 100644 --- a/src/assets/javascripts/templates/search/result/section/index.tsx +++ b/src/assets/javascripts/templates/search/result/section/index.tsx @@ -20,7 +20,7 @@ * IN THE SOFTWARE. */ -import { h, toHTMLElement } from "extensions" +import { h } from "extensions" import { SectionDocument } from "modules" import { truncate } from "utilities" @@ -52,7 +52,7 @@ const css = { export function renderSectionDocument( { location, title, text }: SectionDocument ): HTMLElement { - return toHTMLElement( + return (

    {title}

    diff --git a/src/assets/javascripts/templates/source/index.tsx b/src/assets/javascripts/templates/source/index.tsx index 3b2743cd6..9db265178 100644 --- a/src/assets/javascripts/templates/source/index.tsx +++ b/src/assets/javascripts/templates/source/index.tsx @@ -20,7 +20,7 @@ * IN THE SOFTWARE. */ -import { h, toHTMLElement } from "extensions" +import { h } from "extensions" /* ---------------------------------------------------------------------------- * Data @@ -48,7 +48,7 @@ const css = { export function renderSource( facts: any // TODO: add typings ): HTMLElement { - return toHTMLElement( + return (
      {facts.map((fact: any) =>
    • {fact}
    • )}