refactor: Migrate the app to TypeScript
Convert the React app from JS/JSX to TS/TSX and add type-checking: - Rename sheet-main, book, BookIndex, CharacterSheet to .ts(x) and add types (Fields, Bond, ClassEntry, Spell, CheckMap; loose SavedData for abbreviated save/share payloads) - Add globals.d.ts for CSS imports and the __BOOK_DATA__ global - tsconfig.json (strict, noEmit) and a 'typecheck' npm script - webpack: handle ts/tsx via @babel/preset-typescript - Enforce types with a tracked pre-commit hook (core.hooksPath), wired up automatically via the 'prepare' script - Update stale Justfile format target for the src/ layout Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -44,8 +44,8 @@ module.exports = (env, argv) => {
|
||||
|
||||
return {
|
||||
entry: {
|
||||
sheet: "./src/sheet-main.jsx",
|
||||
book: "./src/book.js",
|
||||
sheet: "./src/sheet-main.tsx",
|
||||
book: "./src/book.tsx",
|
||||
},
|
||||
output: {
|
||||
filename: isProd ? "[name].[contenthash].js" : "[name].js",
|
||||
@@ -56,11 +56,13 @@ module.exports = (env, argv) => {
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.(js|jsx)$/,
|
||||
test: /\.(js|jsx|ts|tsx)$/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: "babel-loader",
|
||||
options: { presets: ["@babel/preset-react"] },
|
||||
options: {
|
||||
presets: ["@babel/preset-react", "@babel/preset-typescript"],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -73,7 +75,7 @@ module.exports = (env, argv) => {
|
||||
],
|
||||
},
|
||||
resolve: {
|
||||
extensions: [".js", ".jsx"],
|
||||
extensions: [".ts", ".tsx", ".js", ".jsx"],
|
||||
},
|
||||
plugins: [
|
||||
...(isProd
|
||||
|
||||
Reference in New Issue
Block a user