mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-03 07:57:22 +00:00
Enable TypeScript strict mode
This commit is contained in:
12 files changed
+229
-13
No files matched your search
Generated
+20
@@ -106,6 +106,7 @@
|
||||
"@testing-library/jest-dom": "^6.6.3",
|
||||
"@testing-library/react": "^16.3.0",
|
||||
"@testing-library/user-event": "^14.6.1",
|
||||
"@types/jsdom": "^27.0.0",
|
||||
"@types/jszip": "^3.4.0",
|
||||
"@types/node": "^22.5.5",
|
||||
"@types/nunjucks": "^3.2.6",
|
||||
@@ -5796,6 +5797,18 @@
|
||||
"@types/unist": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/jsdom": {
|
||||
"version": "27.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-27.0.0.tgz",
|
||||
"integrity": "sha512-NZyFl/PViwKzdEkQg96gtnB8wm+1ljhdDay9ahn4hgb+SfVtPCbm3TlmDUFXTA+MGN3CijicnMhG18SI5H3rFw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"@types/tough-cookie": "*",
|
||||
"parse5": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/json-schema": {
|
||||
"version": "7.0.15",
|
||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
|
||||
@@ -5908,6 +5921,13 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/tough-cookie": {
|
||||
"version": "4.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.5.tgz",
|
||||
"integrity": "sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/trusted-types": {
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
|
||||
|
||||
@@ -117,6 +117,7 @@
|
||||
"@testing-library/jest-dom": "^6.6.3",
|
||||
"@testing-library/react": "^16.3.0",
|
||||
"@testing-library/user-event": "^14.6.1",
|
||||
"@types/jsdom": "^27.0.0",
|
||||
"@types/jszip": "^3.4.0",
|
||||
"@types/node": "^22.5.5",
|
||||
"@types/nunjucks": "^3.2.6",
|
||||
|
||||
@@ -1173,7 +1173,7 @@ export function AIProviderConfigDialog({
|
||||
|
||||
<div className="space-y-3">
|
||||
<Label className="text-sm font-medium">{t('paymentMethod')}</Label>
|
||||
<Tabs value={paymentMethod} onValueChange={(value: 'stripe' | 'lightning') => setPaymentMethod(value)} className="w-full">
|
||||
<Tabs value={paymentMethod} onValueChange={(value) => setPaymentMethod(value as 'stripe' | 'lightning')} className="w-full">
|
||||
<TabsList className="grid w-full grid-cols-2">
|
||||
<TabsTrigger value="stripe" className="flex items-center gap-2">
|
||||
<CreditCard className="h-4 w-4" />
|
||||
|
||||
@@ -9,7 +9,7 @@ import { getSentryInstance } from '@/lib/sentry';
|
||||
interface ErrorBoundaryProps {
|
||||
children: ReactNode;
|
||||
fallback?: ReactNode | ((props: FallbackProps) => ReactNode);
|
||||
onError?: (error: Error, info: { componentStack: string | null }) => void;
|
||||
onError?: (error: Error, info: { componentStack?: string | null }) => void;
|
||||
/** Whether to report errors to Sentry (default: true) */
|
||||
reportToSentry?: boolean;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ export function ErrorBoundary({
|
||||
onError,
|
||||
reportToSentry = true,
|
||||
}: ErrorBoundaryProps) {
|
||||
const handleError = (error: Error, info: { componentStack: string | null }) => {
|
||||
const handleError = (error: Error, info: { componentStack?: string | null }) => {
|
||||
// Log error details for debugging
|
||||
console.error('ErrorBoundary caught an error:', error, info);
|
||||
|
||||
|
||||
@@ -5,12 +5,14 @@ import { useCurrentUser } from "./useCurrentUser";
|
||||
|
||||
import type { NostrEvent } from "@nostrify/nostrify";
|
||||
|
||||
export function useNostrPublish(): UseMutationResult<NostrEvent> {
|
||||
type NostrEventInput = Pick<NostrEvent, 'kind' | 'content'> & Partial<Pick<NostrEvent, 'tags' | 'created_at'>>;
|
||||
|
||||
export function useNostrPublish(): UseMutationResult<NostrEvent, Error, NostrEventInput> {
|
||||
const { nostr } = useNostr();
|
||||
const { user } = useCurrentUser();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (t: Omit<NostrEvent, 'id' | 'pubkey' | 'sig'>) => {
|
||||
mutationFn: async (t: NostrEventInput) => {
|
||||
if (user) {
|
||||
const tags = t.tags ?? [];
|
||||
|
||||
|
||||
@@ -661,7 +661,7 @@ export class SessionManager {
|
||||
console.error('AI generation error:', error);
|
||||
|
||||
// Handle user cancellation
|
||||
if (error instanceof OpenAI.APIUserAbortError || error?.name === 'AbortError') {
|
||||
if (error instanceof OpenAI.APIUserAbortError || (error instanceof Error && error.name === 'AbortError')) {
|
||||
return; // User cancelled
|
||||
}
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ export function esmPlugin(options: EsmPluginOptions): Plugin {
|
||||
let current: string | undefined = base;
|
||||
while (current && current.length) {
|
||||
// Remove the last package from the path (handling scoped packages like @scope/name)
|
||||
const next = current.replace(/\/node_modules\/(@[^/]+\/)?[^/]+$/, "");
|
||||
const next: string = current.replace(/\/node_modules\/(@[^/]+\/)?[^/]+$/, "");
|
||||
if (next === current) break;
|
||||
current = next;
|
||||
const candidate = `${current}/node_modules/${name}`;
|
||||
|
||||
@@ -130,7 +130,7 @@ describe('buildProject', () => {
|
||||
});
|
||||
|
||||
vi.mocked(mockFS.readdir)
|
||||
.mockImplementation(async (path: string, _options?: { withFileTypes: true }) => {
|
||||
.mockImplementation(async (path: string, _options?: { withFileTypes?: boolean }) => {
|
||||
if (path === '/test/project/public') {
|
||||
return [
|
||||
{ name: 'favicon.ico', isDirectory: () => false, isFile: () => true },
|
||||
|
||||
@@ -80,7 +80,7 @@ export class MkdirCommand implements ShellCommand {
|
||||
// Create the directory
|
||||
await this.fs.mkdir(absolutePath);
|
||||
} else {
|
||||
return createErrorResult(`${this.name}: ${dirPath}: ${error.message}`);
|
||||
return createErrorResult(`${this.name}: ${dirPath}: ${error instanceof Error ? error.message : String(error)}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ export class TouchCommand implements ShellCommand {
|
||||
await this.fs.writeFile(absolutePath, '', 'utf8');
|
||||
} else {
|
||||
// Other error (permission, etc.)
|
||||
return createErrorResult(`${this.name}: ${filePath}: ${error.message}`);
|
||||
return createErrorResult(`${this.name}: ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,195 @@
|
||||
[1mdiff --git a/package-lock.json b/package-lock.json[m
|
||||
[1mindex cee59369..035fc334 100644[m
|
||||
[1m--- a/package-lock.json[m
|
||||
[1m+++ b/package-lock.json[m
|
||||
[36m@@ -106,6 +106,7 @@[m
|
||||
"@testing-library/jest-dom": "^6.6.3",[m
|
||||
"@testing-library/react": "^16.3.0",[m
|
||||
"@testing-library/user-event": "^14.6.1",[m
|
||||
[32m+[m[32m "@types/jsdom": "^27.0.0",[m
|
||||
"@types/jszip": "^3.4.0",[m
|
||||
"@types/node": "^22.5.5",[m
|
||||
"@types/nunjucks": "^3.2.6",[m
|
||||
[36m@@ -5796,6 +5797,18 @@[m
|
||||
"@types/unist": "*"[m
|
||||
}[m
|
||||
},[m
|
||||
[32m+[m[32m "node_modules/@types/jsdom": {[m
|
||||
[32m+[m[32m "version": "27.0.0",[m
|
||||
[32m+[m[32m "resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-27.0.0.tgz",[m
|
||||
[32m+[m[32m "integrity": "sha512-NZyFl/PViwKzdEkQg96gtnB8wm+1ljhdDay9ahn4hgb+SfVtPCbm3TlmDUFXTA+MGN3CijicnMhG18SI5H3rFw==",[m
|
||||
[32m+[m[32m "dev": true,[m
|
||||
[32m+[m[32m "license": "MIT",[m
|
||||
[32m+[m[32m "dependencies": {[m
|
||||
[32m+[m[32m "@types/node": "*",[m
|
||||
[32m+[m[32m "@types/tough-cookie": "*",[m
|
||||
[32m+[m[32m "parse5": "^7.0.0"[m
|
||||
[32m+[m[32m }[m
|
||||
[32m+[m[32m },[m
|
||||
"node_modules/@types/json-schema": {[m
|
||||
"version": "7.0.15",[m
|
||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",[m
|
||||
[36m@@ -5908,6 +5921,13 @@[m
|
||||
"dev": true,[m
|
||||
"license": "MIT"[m
|
||||
},[m
|
||||
[32m+[m[32m "node_modules/@types/tough-cookie": {[m
|
||||
[32m+[m[32m "version": "4.0.5",[m
|
||||
[32m+[m[32m "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.5.tgz",[m
|
||||
[32m+[m[32m "integrity": "sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==",[m
|
||||
[32m+[m[32m "dev": true,[m
|
||||
[32m+[m[32m "license": "MIT"[m
|
||||
[32m+[m[32m },[m
|
||||
"node_modules/@types/trusted-types": {[m
|
||||
"version": "2.0.7",[m
|
||||
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",[m
|
||||
[1mdiff --git a/package.json b/package.json[m
|
||||
[1mindex 7dc81e30..b7742d3a 100644[m
|
||||
[1m--- a/package.json[m
|
||||
[1m+++ b/package.json[m
|
||||
[36m@@ -117,6 +117,7 @@[m
|
||||
"@testing-library/jest-dom": "^6.6.3",[m
|
||||
"@testing-library/react": "^16.3.0",[m
|
||||
"@testing-library/user-event": "^14.6.1",[m
|
||||
[32m+[m[32m "@types/jsdom": "^27.0.0",[m
|
||||
"@types/jszip": "^3.4.0",[m
|
||||
"@types/node": "^22.5.5",[m
|
||||
"@types/nunjucks": "^3.2.6",[m
|
||||
[1mdiff --git a/src/components/AIProviderConfigDialog.tsx b/src/components/AIProviderConfigDialog.tsx[m
|
||||
[1mindex e38a614a..94a11e9c 100644[m
|
||||
[1m--- a/src/components/AIProviderConfigDialog.tsx[m
|
||||
[1m+++ b/src/components/AIProviderConfigDialog.tsx[m
|
||||
[36m@@ -1173,7 +1173,7 @@[m [mexport function AIProviderConfigDialog({[m
|
||||
[m
|
||||
<div className="space-y-3">[m
|
||||
<Label className="text-sm font-medium">{t('paymentMethod')}</Label>[m
|
||||
[31m- <Tabs value={paymentMethod} onValueChange={(value: 'stripe' | 'lightning') => setPaymentMethod(value)} className="w-full">[m
|
||||
[32m+[m[32m <Tabs value={paymentMethod} onValueChange={(value) => setPaymentMethod(value as 'stripe' | 'lightning')} className="w-full">[m
|
||||
<TabsList className="grid w-full grid-cols-2">[m
|
||||
<TabsTrigger value="stripe" className="flex items-center gap-2">[m
|
||||
<CreditCard className="h-4 w-4" />[m
|
||||
[1mdiff --git a/src/components/ErrorBoundary.tsx b/src/components/ErrorBoundary.tsx[m
|
||||
[1mindex 4d390a4d..f44501f5 100644[m
|
||||
[1m--- a/src/components/ErrorBoundary.tsx[m
|
||||
[1m+++ b/src/components/ErrorBoundary.tsx[m
|
||||
[36m@@ -9,7 +9,7 @@[m [mimport { getSentryInstance } from '@/lib/sentry';[m
|
||||
interface ErrorBoundaryProps {[m
|
||||
children: ReactNode;[m
|
||||
fallback?: ReactNode | ((props: FallbackProps) => ReactNode);[m
|
||||
[31m- onError?: (error: Error, info: { componentStack: string | null }) => void;[m
|
||||
[32m+[m[32m onError?: (error: Error, info: { componentStack?: string | null }) => void;[m
|
||||
/** Whether to report errors to Sentry (default: true) */[m
|
||||
reportToSentry?: boolean;[m
|
||||
}[m
|
||||
[36m@@ -91,7 +91,7 @@[m [mexport function ErrorBoundary({[m
|
||||
onError,[m
|
||||
reportToSentry = true,[m
|
||||
}: ErrorBoundaryProps) {[m
|
||||
[31m- const handleError = (error: Error, info: { componentStack: string | null }) => {[m
|
||||
[32m+[m[32m const handleError = (error: Error, info: { componentStack?: string | null }) => {[m
|
||||
// Log error details for debugging[m
|
||||
console.error('ErrorBoundary caught an error:', error, info);[m
|
||||
[m
|
||||
[1mdiff --git a/src/hooks/useNostrPublish.ts b/src/hooks/useNostrPublish.ts[m
|
||||
[1mindex b9a3bc25..5d790626 100644[m
|
||||
[1m--- a/src/hooks/useNostrPublish.ts[m
|
||||
[1m+++ b/src/hooks/useNostrPublish.ts[m
|
||||
[36m@@ -5,12 +5,14 @@[m [mimport { useCurrentUser } from "./useCurrentUser";[m
|
||||
[m
|
||||
import type { NostrEvent } from "@nostrify/nostrify";[m
|
||||
[m
|
||||
[31m-export function useNostrPublish(): UseMutationResult<NostrEvent> {[m
|
||||
[32m+[m[32mtype NostrEventInput = Pick<NostrEvent, 'kind' | 'content'> & Partial<Pick<NostrEvent, 'tags' | 'created_at'>>;[m
|
||||
[32m+[m
|
||||
[32m+[m[32mexport function useNostrPublish(): UseMutationResult<NostrEvent, Error, NostrEventInput> {[m
|
||||
const { nostr } = useNostr();[m
|
||||
const { user } = useCurrentUser();[m
|
||||
[m
|
||||
return useMutation({[m
|
||||
[31m- mutationFn: async (t: Omit<NostrEvent, 'id' | 'pubkey' | 'sig'>) => {[m
|
||||
[32m+[m[32m mutationFn: async (t: NostrEventInput) => {[m
|
||||
if (user) {[m
|
||||
const tags = t.tags ?? [];[m
|
||||
[m
|
||||
[1mdiff --git a/src/lib/SessionManager.ts b/src/lib/SessionManager.ts[m
|
||||
[1mindex a6ebaceb..b812fb0b 100644[m
|
||||
[1m--- a/src/lib/SessionManager.ts[m
|
||||
[1m+++ b/src/lib/SessionManager.ts[m
|
||||
[36m@@ -661,7 +661,7 @@[m [mexport class SessionManager {[m
|
||||
console.error('AI generation error:', error);[m
|
||||
[m
|
||||
// Handle user cancellation[m
|
||||
[31m- if (error instanceof OpenAI.APIUserAbortError || error?.name === 'AbortError') {[m
|
||||
[32m+[m[32m if (error instanceof OpenAI.APIUserAbortError || (error && typeof error === 'object' && 'name' in error && error.name === 'AbortError')) {[m
|
||||
return; // User cancelled[m
|
||||
}[m
|
||||
[m
|
||||
[1mdiff --git a/src/lib/build/esmPlugin.ts b/src/lib/build/esmPlugin.ts[m
|
||||
[1mindex 02602cd4..3853fbc9 100644[m
|
||||
[1m--- a/src/lib/build/esmPlugin.ts[m
|
||||
[1m+++ b/src/lib/build/esmPlugin.ts[m
|
||||
[36m@@ -158,7 +158,7 @@[m [mexport function esmPlugin(options: EsmPluginOptions): Plugin {[m
|
||||
let current: string | undefined = base;[m
|
||||
while (current && current.length) {[m
|
||||
// Remove the last package from the path (handling scoped packages like @scope/name)[m
|
||||
[31m- const next = current.replace(/\/node_modules\/(@[^/]+\/)?[^/]+$/, "");[m
|
||||
[32m+[m[32m const next: string = current.replace(/\/node_modules\/(@[^/]+\/)?[^/]+$/, "");[m
|
||||
if (next === current) break;[m
|
||||
current = next;[m
|
||||
const candidate = `${current}/node_modules/${name}`;[m
|
||||
[1mdiff --git a/src/lib/build/index.test.ts b/src/lib/build/index.test.ts[m
|
||||
[1mindex 134f7d5f..e494d1c2 100644[m
|
||||
[1m--- a/src/lib/build/index.test.ts[m
|
||||
[1m+++ b/src/lib/build/index.test.ts[m
|
||||
[36m@@ -130,7 +130,7 @@[m [mdescribe('buildProject', () => {[m
|
||||
});[m
|
||||
[m
|
||||
vi.mocked(mockFS.readdir)[m
|
||||
[31m- .mockImplementation(async (path: string, _options?: { withFileTypes: true }) => {[m
|
||||
[32m+[m[32m .mockImplementation(async (path: string, _options?: { withFileTypes?: boolean }) => {[m
|
||||
if (path === '/test/project/public') {[m
|
||||
return [[m
|
||||
{ name: 'favicon.ico', isDirectory: () => false, isFile: () => true },[m
|
||||
[1mdiff --git a/src/lib/commands/mkdir.ts b/src/lib/commands/mkdir.ts[m
|
||||
[1mindex 82ddd883..13807265 100644[m
|
||||
[1m--- a/src/lib/commands/mkdir.ts[m
|
||||
[1m+++ b/src/lib/commands/mkdir.ts[m
|
||||
[36m@@ -80,7 +80,7 @@[m [mexport class MkdirCommand implements ShellCommand {[m
|
||||
// Create the directory[m
|
||||
await this.fs.mkdir(absolutePath);[m
|
||||
} else {[m
|
||||
[31m- return createErrorResult(`${this.name}: ${dirPath}: ${error.message}`);[m
|
||||
[32m+[m[32m return createErrorResult(`${this.name}: ${dirPath}: ${error instanceof Error ? error.message : String(error)}`);[m
|
||||
}[m
|
||||
}[m
|
||||
}[m
|
||||
[1mdiff --git a/src/lib/commands/touch.ts b/src/lib/commands/touch.ts[m
|
||||
[1mindex bce66f25..bb0b8a9b 100644[m
|
||||
[1m--- a/src/lib/commands/touch.ts[m
|
||||
[1m+++ b/src/lib/commands/touch.ts[m
|
||||
[36m@@ -73,7 +73,7 @@[m [mexport class TouchCommand implements ShellCommand {[m
|
||||
await this.fs.writeFile(absolutePath, '', 'utf8');[m
|
||||
} else {[m
|
||||
// Other error (permission, etc.)[m
|
||||
[31m- return createErrorResult(`${this.name}: ${filePath}: ${error.message}`);[m
|
||||
[32m+[m[32m return createErrorResult(`${this.name}: ${filePath}: ${error instanceof Error ? error.message : String(error)}`);[m
|
||||
}[m
|
||||
}[m
|
||||
[m
|
||||
[1mdiff --git a/tsconfig.json b/tsconfig.json[m
|
||||
[1mindex 56af9ad1..58190179 100644[m
|
||||
[1m--- a/tsconfig.json[m
|
||||
[1m+++ b/tsconfig.json[m
|
||||
[36m@@ -15,11 +15,9 @@[m
|
||||
"jsx": "react-jsx",[m
|
||||
[m
|
||||
/* Linting */[m
|
||||
[31m- "strict": false,[m
|
||||
[31m- "strictNullChecks": true,[m
|
||||
[32m+[m[32m "strict": true,[m
|
||||
"noUnusedLocals": false,[m
|
||||
"noUnusedParameters": false,[m
|
||||
[31m- "noImplicitAny": false,[m
|
||||
"noFallthroughCasesInSwitch": false,[m
|
||||
[m
|
||||
"baseUrl": ".",[m
|
||||
+1
-3
@@ -15,11 +15,9 @@
|
||||
"jsx": "react-jsx",
|
||||
|
||||
/* Linting */
|
||||
"strict": false,
|
||||
"strictNullChecks": true,
|
||||
"strict": true,
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"noImplicitAny": false,
|
||||
"noFallthroughCasesInSwitch": false,
|
||||
|
||||
"baseUrl": ".",
|
||||
|
||||
Reference in new issue
Block a user