From b5d8be356f0a2b40011047949d5eef622fad8fff Mon Sep 17 00:00:00 2001 From: Josias Aurel Date: Fri, 24 May 2024 09:35:36 +0000 Subject: [PATCH 1/5] create ts check action --- .github/workflows/ts-check.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/ts-check.yml diff --git a/.github/workflows/ts-check.yml b/.github/workflows/ts-check.yml new file mode 100644 index 0000000000..0e30bd2d89 --- /dev/null +++ b/.github/workflows/ts-check.yml @@ -0,0 +1,26 @@ +name: TypeScript Check + +on: + pull_request: + types: [opened, reopened, edited] + +jobs: + # Test job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Install Node + uses: actions/setup-node@v3 + with: + node-version: 20.x + + - name: Install Dependencies + run: | + yarn install + + - name: Build Project + run: | + yarn tsc --noEmit From a4b4e48cc8a676fa48a0e7c91100784a1c86dd0b Mon Sep 17 00:00:00 2001 From: JosiasAurel Date: Fri, 24 May 2024 11:10:36 +0100 Subject: [PATCH 2/5] add type definitions for node-statsd --- package.json | 1 + yarn.lock | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/package.json b/package.json index 031c757a89..e17a9fe92d 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "@types/esprima": "^4.0.3", "@types/grecaptcha": "^3.0.4", "@types/js-beautify": "^1.14.3", + "@types/node-statsd": "^0.1.6", "@types/three": "^0.149.0", "@types/throttle-debounce": "^5.0.0", "@types/w3c-web-serial": "^1.0.3" diff --git a/yarn.lock b/yarn.lock index f2f4374a8c..38856f703f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1570,6 +1570,13 @@ dependencies: "@types/unist" "*" +"@types/node-statsd@^0.1.6": + version "0.1.6" + resolved "https://registry.yarnpkg.com/@types/node-statsd/-/node-statsd-0.1.6.tgz#87c2de1f1a1eda6ab4187f4475ee3dc3caa56b8b" + integrity sha512-C3E7STmDzLmXLbIK+C9P5Su6FFW1Ki+Uzjfh6NCBU+5iveeDJl69bmc+0wMSOEymSbPLqPvBsF84mtYDGILlPw== + dependencies: + "@types/node" "*" + "@types/node@*", "@types/node@>=12.12.47", "@types/node@>=13.7.0": version "18.13.0" resolved "https://registry.yarnpkg.com/@types/node/-/node-18.13.0.tgz#0400d1e6ce87e9d3032c19eb6c58205b0d3f7850" From abf24af3f8a44b9cbdc2ef19bf771f5453817c25 Mon Sep 17 00:00:00 2001 From: JosiasAurel Date: Fri, 24 May 2024 11:11:56 +0100 Subject: [PATCH 3/5] add onChange handlers and set the value prop of Input fields --- src/components/big-interactive-pages/login.tsx | 12 ++++++------ src/components/big-interactive-pages/migrate.tsx | 6 +++--- src/components/popups-etc/draft-warning.tsx | 6 +++--- src/components/popups-etc/save-prompt.tsx | 8 ++++---- src/integrations/generate-metadata.ts | 2 +- src/pages/gallery/gallery.tsx | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/components/big-interactive-pages/login.tsx b/src/components/big-interactive-pages/login.tsx index 65fed7e151..b544a43ceb 100644 --- a/src/components/big-interactive-pages/login.tsx +++ b/src/components/big-interactive-pages/login.tsx @@ -36,11 +36,11 @@ export default function Login({ session, email, to }: LoginProps) {

Log In to Sprig

{auth.stage.value === 'EMAIL' ? (<>

Please enter your email address below. We'll send you a code to access all your games.

- + - + undefined} value={auth.email.value} type='email' id='email' autoComplete='email' placeholder='fiona@hackclub.com' bind={auth.email} /> {auth.state.value === 'EMAIL_INCORRECT' &&

Failed sending login code. Did you enter the right email?

} - + @@ -54,9 +54,9 @@ export default function Login({ session, email, to }: LoginProps) {

- + - + undefined} value={auth.code.value} id='code' type='text' maxLength={6} placeholder='123456' bind={auth.code} /> {auth.state.value === 'CODE_INCORRECT' &&

Incorrect login code.

} @@ -70,7 +70,7 @@ export default function DraftWarningModal(props: DraftWarningModalProps) {

You've used Sprig before, so we emailed you a code to log in and access all your games. Enter login code:

- + undefined} value={auth.code.value} maxLength={6} class={styles.center} type='text' bind={auth.code} placeholder='123456' /> @@ -88,4 +88,4 @@ export default function DraftWarningModal(props: DraftWarningModalProps) {
) -} \ No newline at end of file +} diff --git a/src/components/popups-etc/save-prompt.tsx b/src/components/popups-etc/save-prompt.tsx index 076d9f0f58..da5cd77e89 100644 --- a/src/components/popups-etc/save-prompt.tsx +++ b/src/components/popups-etc/save-prompt.tsx @@ -12,7 +12,7 @@ interface SavePromptProps { persistenceState: Signal onClose: () => void } - + export default function SavePrompt(props: SavePromptProps) { const email = useSignal(props.persistenceState.value.session?.user.email ?? '') const emailValid = useComputed(() => isValidEmail(email.value)) @@ -38,7 +38,7 @@ export default function SavePrompt(props: SavePromptProps) { }}>

Enter your email to save your work, we'll send you a link for later:

- + undefined} value={email.value} type='email' autoComplete='email' placeholder='fiona@hackclub.com' bind={email} /> @@ -54,10 +54,10 @@ export default function SavePrompt(props: SavePromptProps) { ) } - + return (
{content}
) -} \ No newline at end of file +} diff --git a/src/integrations/generate-metadata.ts b/src/integrations/generate-metadata.ts index 705069af0b..4ccfbc1ef8 100644 --- a/src/integrations/generate-metadata.ts +++ b/src/integrations/generate-metadata.ts @@ -1,6 +1,6 @@ /** * Astro integration that generatest the game/metadata.json - * + * * How it works: * 1. It walks/scans the ./games/ directory * 2. It searches each file for metadata, if anything isn't found it halts the build/dev diff --git a/src/pages/gallery/gallery.tsx b/src/pages/gallery/gallery.tsx index f00ff63e8d..741e486e63 100644 --- a/src/pages/gallery/gallery.tsx +++ b/src/pages/gallery/gallery.tsx @@ -269,4 +269,4 @@ export default function Gallery({ games, tags }: { games: GameMetadata[], tags:
) -} \ No newline at end of file +} From c39345f8cabe05e2e731b0c08d9632401b971727 Mon Sep 17 00:00:00 2001 From: JosiasAurel Date: Fri, 24 May 2024 11:12:31 +0100 Subject: [PATCH 4/5] silence typescript warnings and set types --- src/components/navbar-editor.tsx | 2 +- src/components/popups-etc/chat-component.tsx | 2 +- src/integrations/generate-metadata.ts | 2 +- src/lib/state.ts | 18 +++++++++--------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/components/navbar-editor.tsx b/src/components/navbar-editor.tsx index 811fe1edfd..3102f2ef7c 100644 --- a/src/components/navbar-editor.tsx +++ b/src/components/navbar-editor.tsx @@ -106,7 +106,7 @@ const prettifyCode = () => { // Set the options for js_beautify const options = { indent_size: 2, // Indent by 2 spaces - brace_style: "collapse,preserve-inline", // Collapse braces and preserve inline + brace_style: "collapse,preserve-inline" as any, // Collapse braces and preserve inline }; const { js_beautify } = beautifier; diff --git a/src/components/popups-etc/chat-component.tsx b/src/components/popups-etc/chat-component.tsx index 59693fb36b..05ed939055 100644 --- a/src/components/popups-etc/chat-component.tsx +++ b/src/components/popups-etc/chat-component.tsx @@ -120,7 +120,7 @@ Answer the questions that follow based on this unless new code is provided.`; } catch (err) { loading.value = false; // info.value = "An error occurred..."; - info.value = err.message; + info.value = (err as Error).message; } }; diff --git a/src/integrations/generate-metadata.ts b/src/integrations/generate-metadata.ts index 4ccfbc1ef8..28e9091cab 100644 --- a/src/integrations/generate-metadata.ts +++ b/src/integrations/generate-metadata.ts @@ -26,7 +26,7 @@ const regexExpr = { * * TODO! */ -const isMetadataValid = (meta: any): boolean => { +const isMetadataValid = (_: any): boolean => { return true; }; diff --git a/src/lib/state.ts b/src/lib/state.ts index 6d1c502135..c842e722d9 100644 --- a/src/lib/state.ts +++ b/src/lib/state.ts @@ -134,23 +134,23 @@ export const themes: Partial> = { export const switchTheme = (themeType: ThemeType) => { theme.value = themeType; - + // store the new theme value in local storage localStorage.setItem("theme", themeType); const themeValue = themes[themeType]; // set the document values const documentStyle = document.body.style; - documentStyle.background = themeValue.background; - document.documentElement.style.setProperty(`--accent`, themeValue.accent); - document.documentElement.style.setProperty(`--accent-dark`, themeValue.accentDark); - document.documentElement.style.setProperty(`--fg-muted-on-accent`, themeValue.fgMutedOnAccent); - documentStyle.color = themeValue.color; - + documentStyle.background = themeValue!.background; + document.documentElement.style.setProperty(`--accent`, themeValue!.accent); + document.documentElement.style.setProperty(`--accent-dark`, themeValue!.accentDark); + document.documentElement.style.setProperty(`--fg-muted-on-accent`, themeValue!.fgMutedOnAccent); + documentStyle.color = themeValue!.color; + // change the color of the text in elements having .copy-container style // These includes pages such as 'Gallery' and 'Your Games' const copyContainer = document.querySelector(".copy-container") as HTMLDivElement; if (copyContainer) { - copyContainer.style.color = themeValue.copyContainerText; + copyContainer.style.color = themeValue!.copyContainerText; } -} \ No newline at end of file +} From bbe73e618988dab2f3a8cb9e5352022a2099a2af Mon Sep 17 00:00:00 2001 From: JosiasAurel Date: Fri, 24 May 2024 11:13:02 +0100 Subject: [PATCH 5/5] remove or comment unused imports --- src/components/navbar-main.tsx | 2 +- src/pages/gallery/gallery.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/navbar-main.tsx b/src/components/navbar-main.tsx index c6f844ed64..7e413f25fd 100644 --- a/src/components/navbar-main.tsx +++ b/src/components/navbar-main.tsx @@ -2,7 +2,7 @@ import { IoAdd, IoLogoGithub, IoOpenOutline } from "react-icons/io5"; import Button from "./design-system/button"; import styles from "./navbar.module.css"; import { SessionInfo } from "../lib/game-saving/account"; -import AnnouncementBanner from "./popups-etc/announcement-banner"; +// import AnnouncementBanner from "./popups-etc/announcement-banner"; interface MainNavbarProps { session: SessionInfo | null; transparent?: boolean; diff --git a/src/pages/gallery/gallery.tsx b/src/pages/gallery/gallery.tsx index 741e486e63..699bf341fa 100644 --- a/src/pages/gallery/gallery.tsx +++ b/src/pages/gallery/gallery.tsx @@ -3,7 +3,7 @@ import { loadThumbnailUrl } from "../../lib/thumbnail"; import { GameMetadata } from "../../lib/game-saving/gallery"; import Button from "../../components/design-system/button"; import Input from "../../components/design-system/input"; -import { IoCaretDown, IoSearch, IoClose } from "react-icons/io5"; +import { IoCaretDown, IoSearch } from "react-icons/io5"; import "./gallery.css"; enum SortOrder {