From a5ac702820de5345226dbbaf775c4f5a72ef16cd Mon Sep 17 00:00:00 2001 From: AAGaming Date: Sat, 28 May 2022 20:54:25 -0400 Subject: [PATCH] fix typescript AGAIN, fix icons, ignore pnpm lock --- .gitignore | 3 +++ globals.d.ts | 5 +++++ src/deck-components/Spinner.tsx | 2 +- src/webpack.ts | 7 +++---- tsconfig.json | 5 +++-- 5 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 globals.d.ts diff --git a/.gitignore b/.gitignore index 6776fe7..2f8f83d 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,6 @@ Thumbs.db dist/ research/ + +# PNPM lockfile +pnpm-lock.yaml diff --git a/globals.d.ts b/globals.d.ts new file mode 100644 index 0000000..0dfe9ff --- /dev/null +++ b/globals.d.ts @@ -0,0 +1,5 @@ +declare global { + interface Window { + SP_REACT: typeof React; + } +} \ No newline at end of file diff --git a/src/deck-components/Spinner.tsx b/src/deck-components/Spinner.tsx index 72d9c73..0f4bb0f 100644 --- a/src/deck-components/Spinner.tsx +++ b/src/deck-components/Spinner.tsx @@ -12,5 +12,5 @@ import { IconsModule } from '../webpack'; // } export const Spinner = Object.values(IconsModule).find((mod: any) => - mod?.toString()?.includes("Spinner)}),a.createElement(\"path\",{d:\"M18 "), + mod?.toString && /Spinner\)}\),.\.createElement\(\"path\",{d:\"M18 /.test(mod.toString()) ) as FC<{}>; \ No newline at end of file diff --git a/src/webpack.ts b/src/webpack.ts index 09f0fba..b335d12 100644 --- a/src/webpack.ts +++ b/src/webpack.ts @@ -58,14 +58,13 @@ export const CommonUIModule = allModules.find((m: Module) => { return false; }); -export const IconsModule = allModules.find((m: Module) => { - if (typeof m !== "object") return undefined; +export const IconsModule = findModule((m: Module) => { + if (typeof m !== "object") return false; for (let prop in m) { - if (m[prop]?.toString()?.includes("Spinner)}),a.createElement(\"path\",{d:\"M18 ")) return true; + if (m[prop]?.toString && /Spinner\)}\),.\.createElement\(\"path\",{d:\"M18 /.test(m[prop].toString())) return true; } return false; }) - export const Router = findModuleChild((m: Module) => { if (typeof m !== "object") return undefined; for (let prop in m) { diff --git a/tsconfig.json b/tsconfig.json index 7c536b1..869d3b6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,8 @@ "outDir": "dist", "module": "ESNext", "target": "ES2020", - "jsx": "react-jsx", + "jsx": "react", + "jsxFactory": "SP_REACT.createElement", "declaration": true, "moduleResolution": "node", "noUnusedLocals": true, @@ -17,6 +18,6 @@ "allowSyntheticDefaultImports": true, "skipLibCheck": true }, - "include": ["src"], + "include": ["src", "globals.d.ts"], "exclude": ["node_modules"] }