From cc06c6752c47b3345e3d98ec7e39e073d2d76d70 Mon Sep 17 00:00:00 2001 From: Claas Date: Sat, 28 Sep 2024 21:46:01 +0200 Subject: [PATCH] Find workaround for typescript not understanding itself --- app/package.json | 2 +- app/src/components/AppContext.jsx | 8 ++++---- app/src/components/Onboarding.jsx | 6 +++--- app/src/routes/chat.jsx | 1 + app/src/routes/index.jsx | 8 ++++---- app/src/routes/invite.jsx | 10 +++++----- app/src/routes/join.jsx | 9 +++++---- app/tsconfig.node.json | 2 +- 8 files changed, 24 insertions(+), 22 deletions(-) diff --git a/app/package.json b/app/package.json index f7cfb28..1754c43 100644 --- a/app/package.json +++ b/app/package.json @@ -5,7 +5,7 @@ "type": "module", "scripts": { "dev": "vite", - "build": "vite build", + "build": "tsc && vite build", "preview": "vite preview", "wasm": "wasm-pack build ../core" }, diff --git a/app/src/components/AppContext.jsx b/app/src/components/AppContext.jsx index 797da4d..df2c19a 100644 --- a/app/src/components/AppContext.jsx +++ b/app/src/components/AppContext.jsx @@ -1,11 +1,11 @@ -import { createContext, createEffect, createMemo, useContext } from "solid-js"; +import { createContext, createEffect, useContext } from "solid-js"; //TODO register rust wasm pack package as package in workspace import { Client } from "../../../core/pkg"; import { createStore } from "solid-js/store"; /** - * @import { ParentProps, Context, EffectFunction } from "solid-js"; - * @import { Friend } from "../../../core/pkg"; + * @import { ParentProps, Context, EffectFunction } from "solid-js" + * @import { Friend } from "../../../core/pkg" * @typedef {{id: string, friend: Friend, messages: string[]}} Group * TODO these need to be derivated from the rust types which should be automated * @typedef {{type: "Welcome", group_id: string, friend: Friend}} Welcome @@ -134,7 +134,7 @@ function receiveMessage(event) { } // Create new socket when id changes -const socket = createMemo( +createEffect( /** @type {EffectFunction}*/ (previousSocket) => { console.debug("Previous socket", previousSocket); if (previousSocket) previousSocket.close(); diff --git a/app/src/components/Onboarding.jsx b/app/src/components/Onboarding.jsx index fb2b458..d401329 100644 --- a/app/src/components/Onboarding.jsx +++ b/app/src/components/Onboarding.jsx @@ -1,6 +1,6 @@ -/** - * @import { Signal, JSX, VoidProps, Setter } from "solid-js" - */ +//@ts-expect-error TS6192 Can not handle new JSDoc syntax (yet?) +// https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#the-jsdoc-@import-tag +/** @import { JSX, VoidProps } from "solid-js" */ /** * diff --git a/app/src/routes/chat.jsx b/app/src/routes/chat.jsx index 1f47683..cb6a9dd 100644 --- a/app/src/routes/chat.jsx +++ b/app/src/routes/chat.jsx @@ -1,6 +1,7 @@ import { Navigate, useParams } from "@solidjs/router"; import { createMemo, For, Show } from "solid-js"; import { useAppContext, messagesUrl } from "../components/AppContext"; +//@ts-expect-error TS6192 Can not handle new JSDoc syntax (yet?) /** @import { JSX } from "solid-js" */ export default function Chat() { diff --git a/app/src/routes/index.jsx b/app/src/routes/index.jsx index 2200b43..1aa29c8 100644 --- a/app/src/routes/index.jsx +++ b/app/src/routes/index.jsx @@ -1,9 +1,9 @@ -import { createEffect, createMemo, createSignal, For, Show } from "solid-js"; +import { Show } from "solid-js"; import Onboarding from "../components/Onboarding"; import { useAppContext } from "../components/AppContext"; -/** - * @import { Signal, JSX, Accessor } from "solid-js" - */ +//@ts-expect-error TS6192 Can not handle new JSDoc syntax (yet?) +// https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#the-jsdoc-@import-tag +/** @import { Signal, JSX, Accessor } from "solid-js" */ export default function () { const [app, setApp] = useAppContext(); diff --git a/app/src/routes/invite.jsx b/app/src/routes/invite.jsx index db59288..0f8245c 100644 --- a/app/src/routes/invite.jsx +++ b/app/src/routes/invite.jsx @@ -1,9 +1,9 @@ -import { Navigate, useNavigate } from "@solidjs/router"; +import { useNavigate } from "@solidjs/router"; import { useAppContext } from "../components/AppContext"; -import { createEffect, createSignal, Show } from "solid-js"; -/** - * @import { JSX, Signal, Accessor, EffectFunction } from "solid-js"; - */ +import { createEffect, Show } from "solid-js"; +//@ts-expect-error TS6192 Can not handle new JSDoc syntax (yet?) +// https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#the-jsdoc-@import-tag +/** @import { JSX, Signal, Accessor, EffectFunction } from "solid-js" */ export default function Invite() { const navigate = useNavigate(); diff --git a/app/src/routes/join.jsx b/app/src/routes/join.jsx index b5316f6..8dcd787 100644 --- a/app/src/routes/join.jsx +++ b/app/src/routes/join.jsx @@ -3,10 +3,11 @@ import { createResource, Match, Switch } from "solid-js"; import { useAppContext, messagesUrl } from "../components/AppContext"; import { decode_key_package } from "../../../core/pkg/meal"; -/** - * @import { JSX, Accessor } from "solid-js"; - * @import { Group } from "../components/AppContext"; - */ +//@ts-expect-error TS6192 Can not handle new JSDoc syntax (yet?) +// https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#the-jsdoc-@import-tag +/**@import { JSX, Accessor } from "solid-js" */ +//@ts-expect-error TS6192 See above +/** @import { Group } from "../components/AppContext" */ /** * @returns {JSX.Element} diff --git a/app/tsconfig.node.json b/app/tsconfig.node.json index 97ede7e..8762794 100644 --- a/app/tsconfig.node.json +++ b/app/tsconfig.node.json @@ -7,5 +7,5 @@ "allowSyntheticDefaultImports": true, "strict": true }, - "include": ["vite.config.ts"] + "include": ["vite.config.js"] } -- 2.51.2