Update typescript configs

This commit is contained in:
Declan Chidlow 2024-07-13 20:18:12 +08:00
parent 13db769a22
commit bfd2ea2094
5 changed files with 53 additions and 31 deletions

View file

@ -1,28 +1,32 @@
{ {
"compilerOptions": { "compilerOptions": {
// Enable latest features // Enable latest features
"lib": ["ESNext", "DOM"], "lib": ["ESNext", "DOM", "DOM.Iterable"],
"target": "ESNext", "target": "ESNext",
"module": "ESNext", "module": "ESNext",
"moduleDetection": "force", "moduleDetection": "force",
"jsx": "react-jsx", "jsx": "react-jsx",
"allowJs": true, "allowJs": true,
// Bundler mode // Bundler mode
"moduleResolution": "bundler", "moduleResolution": "bundler",
"allowImportingTsExtensions": true, "allowImportingTsExtensions": true,
"verbatimModuleSyntax": true, "verbatimModuleSyntax": true,
"noEmit": true, "noEmit": true,
// Best practices // Best practices
"strict": true, "strict": true,
"skipLibCheck": true, "skipLibCheck": true,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
// Some stricter flags (enabled)
// Some stricter flags (disabled by default) "noUnusedLocals": true,
"noUnusedLocals": false, "noUnusedParameters": true,
"noUnusedParameters": false, "noPropertyAccessFromIndexSignature": true,
"noPropertyAccessFromIndexSignature": false // Additional improvements
"esModuleInterop": true,
"resolveJsonModule": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"useDefineForClassFields": true,
"types": ["bun-types"]
}, },
"include": ["src/**/*"], "include": ["src/**/*"],
"exclude": ["node_modules", "dist"] "exclude": ["node_modules", "dist"]

View file

@ -1,4 +1,4 @@
import { Route, BrowserRouter, Routes, useLocation } from 'react-router-dom'; import { Route, BrowserRouter, Routes } from 'react-router-dom';
import Home from './pages/Home'; import Home from './pages/Home';
import './App.css'; import './App.css';
import '@revoltchat/ui/src/styles/dark.css'; import '@revoltchat/ui/src/styles/dark.css';
@ -9,10 +9,10 @@ import ServerDashboard from './pages/ServerDashboard/ServerDashboard';
import localforage from 'localforage'; import localforage from 'localforage';
import TexPage from './pages/Tex'; import TexPage from './pages/Tex';
const API_URL = import.meta.env.VITE_API_URL?.toString() const API_URL = import.meta.env['VITE_API_URL']?.toString()
|| 'http://localhost:9000'; || 'http://localhost:9000';
const BOT_PREFIX = import.meta.env.VITE_BOT_PREFIX?.toString() const BOT_PREFIX = import.meta.env['VITE_BOT_PREFIX']?.toString()
|| '/'; || '/';
function App() { function App() {

View file

@ -1,4 +1,4 @@
import { FunctionComponent, useState } from "react"; import { FunctionComponent } from "react";
import './styles/CategorySelector.css'; import './styles/CategorySelector.css';
const CategorySelector: FunctionComponent<{ keys: { id: string, name: string }[], selected: string, onChange: (key: string) => void }> = (props) => { const CategorySelector: FunctionComponent<{ keys: { id: string, name: string }[], selected: string, onChange: (key: string) => void }> = (props) => {

View file

@ -106,14 +106,14 @@ const ServerDashboard: FunctionComponent = () => {
const server: Server = res.data.server; const server: Server = res.data.server;
setServerInfo(server); setServerInfo(server);
setPrefix(server.serverConfig?.prefix || ''); setPrefix(server.serverConfig?.['prefix'] || '');
setPrefixAllowSpace(!!server.serverConfig?.spaceAfterPrefix); setPrefixAllowSpace(!!server.serverConfig?.['spaceAfterPrefix']);
setDmOnKick(!!server.serverConfig?.dmOnKick); setDmOnKick(!!server.serverConfig?.['dmOnKick']);
setDmOnWarn(!!server.serverConfig?.dmOnWarn); setDmOnWarn(!!server.serverConfig?.['dmOnWarn']);
setContact(server.serverConfig?.contact || ''); setContact(server.serverConfig?.['contact'] || '');
setBotManagers(server.serverConfig?.botManagers ?? []); setBotManagers(server.serverConfig?.['botManagers'] ?? []);
setModerators(server.serverConfig?.moderators ?? []); setModerators(server.serverConfig?.['moderators'] ?? []);
loadAutomodInfo(server); loadAutomodInfo(server);
} catch(e: any) { } catch(e: any) {

View file

@ -1,20 +1,38 @@
{ {
"compilerOptions": { "compilerOptions": {
// Enable latest features
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"target": "ESNext", "target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext", "module": "ESNext",
"jsx": "react-jsx",
"allowJs": true,
// Bundler mode
"moduleResolution": "Node", "moduleResolution": "Node",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
// Best practices
"strict": true,
"skipLibCheck": true,
"noEmit": true,
// Some stricter flags (enabled)
"noUnusedLocals": true,
"noUnusedParameters": true,
"noPropertyAccessFromIndexSignature": true,
// Additional improvements
"useDefineForClassFields": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"noEmit": true, "baseUrl": ".",
"jsx": "react-jsx" "paths": {
"@/*": ["./src/*"]
}, },
"include": ["./src"] "incremental": true
},
"include": ["./src/**/*"],
"exclude": ["node_modules", "dist"]
} }