Skip to content

Commit

Permalink
full typescript convesion, no outstanding errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mattlohkamp committed Jan 18, 2025
1 parent 9df404f commit 85142ae
Show file tree
Hide file tree
Showing 37 changed files with 752 additions and 553 deletions.
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"js/ts.implicitProjectConfig.checkJs": false,
"typescript.validate.enable": false,
"js/ts.implicitProjectConfig.checkJs": true,
"javascript.suggestionActions.enabled": false,
"vue.server.hybridMode": true
"vue.server.hybridMode": true,
"typescript.validate.enable": true,
}
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- [x] **consistent naming** replace 'folder' with 'directory' globally
- [x] **checkpoint!** make it to feature parity with original vanilla js prototype
- [ ] **typing** convert codebase to typescript, remove redundant JSDOC
- [x] **typing** convert codebase to typescript, remove redundant JSDOC
- [ ] **consistent typing** evaluate usage of null versus undefined throughout (undefined is incidentally nothing / 'missing', null is nothing on purpose?)
- [ ] **testing** unit testing, especially in util funcs
- [ ] **testing** api mocks
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@
</div>
</noscript>

<script type="module" src="/src/index.jsx"></script>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
5 changes: 2 additions & 3 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{
"compilerOptions": {
"lib": [
"es2017",
"es2021",
"dom"
],
"checkJs": true,
"jsx": "react-jsx",
"resolveJsonModule": true,
"esModuleInterop": true,
"noImplicitAny": false,
"strict": false // Disable all strict TypeScript checks
// "noImplicitAny": false,
},
"exclude": [
"node_modules",
Expand Down
107 changes: 93 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@
"license": "CC0-1.0",
"dependencies": {
"@reduxjs/toolkit": "^2.5.0",
"@types/react-redux": "^7.1.34",
"@types/reselect": "^2.2.0",
"@vitejs/plugin-react": "^4.3.4",
"ms": "^2.1.3",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-redux": "^9.2.0",
"reselect": "^5.1.1",
"typescript": "^5.7.3",
"vite": "^6.0.3"
},
"devDependencies": {
"@types/ms": "^0.7.34",
"@types/react": "^19.0.1",
"@types/react-dom": "^19.0.2",
"@types/react": "^19.0.7",
"@types/react-dom": "^19.0.3",
"vite-plugin-html": "^3.2.2"
}
}
12 changes: 6 additions & 6 deletions src/App.jsx → src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import CurrentBattlesContainer from "./components/CurrentBattlesContainer.jsx";
import BattleURLInput from "./components/BattleURLInput.jsx";
import BattleDetails from "./components/BattleDetails.jsx";
import DirectoryNameOptions from "./components/DirectoryNameOptions.jsx";
import DirectoryNameResults from "./components/DirectoryNameResults.jsx";
import DirectoryNameTemplate from "./components/DirectoryNameTemplate.jsx";
import CurrentBattlesContainer from "./components/CurrentBattlesContainer";
import BattleURLInput from "./components/BattleURLInput";
import BattleDetails from "./components/BattleDetails";
import DirectoryNameOptions from "./components/DirectoryNameOptions";
import DirectoryNameResults from "./components/DirectoryNameResults";
import DirectoryNameTemplate from "./components/DirectoryNameTemplate";

export default function App() {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { useSelector } from "react-redux";
import {
APIBattleTypeLabels,
getAvatarURL,
getUserProfileURL,
} from "../constants.js";
import { APIBattleTypeLabels, getAvatarURL } from "../constants.js";
import selectBattleDetails from "../state/selectBattleDetails.js";

export default function BattleDetails() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import { useDispatch, useSelector } from "react-redux"; // Example: if using Redux for global state
import { selectBattleURL, setBattleURL } from "../state/battleURLSlice.js";
import { fetchBattleData } from "../state/battleDataSlice.js";
import { MatchBattleIdFromBattleURL } from "../utils.js";
import { APIDomain } from "../constants.js";
import { selectBattleURL, setBattleURL } from "../state/battleURLSlice";
import { fetchBattleData } from "../state/battleDataSlice";
import { MatchBattleIdFromBattleURL } from "../utils";
import { APIDomain } from "../constants";
import store from "../state/store";

export default function BattleURLInput() {
const dispatch = useDispatch();
const dispatch: typeof store.dispatch = useDispatch();
const battleURL = useSelector(selectBattleURL);
return (
<form
onSubmitCapture={(e) => {
const battleId = (
battleURL.match(MatchBattleIdFromBattleURL) ?? []
).pop();
dispatch(fetchBattleData(battleId));
if (battleURL !== null) {
const battleId = (
battleURL.match(MatchBattleIdFromBattleURL) ?? []
).pop();
if (battleId !== undefined) {
dispatch(fetchBattleData(parseInt(battleId)));
}
}
e.preventDefault();
}}>
<label>
Expand Down
Loading

0 comments on commit 85142ae

Please sign in to comment.