From 11472a4468acb9de329bc6c1f6c7e6e2458de9a7 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Mon, 13 Jan 2025 21:22:24 +0100 Subject: [PATCH 1/2] feat: react typescript setup --- templates/react-ts-starter/package.json | 4 ++- templates/react-ts-starter/src/main.tsx | 6 ++--- templates/react-ts-starter/src/vite-env.d.ts | 1 + templates/react-ts-starter/tsconfig.app.json | 26 +++++++++++++++++++ templates/react-ts-starter/tsconfig.json | 8 +++--- templates/react-ts-starter/tsconfig.node.json | 24 +++++++++++++++++ .../{vite.config.js => vite.config.ts} | 0 7 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 templates/react-ts-starter/src/vite-env.d.ts create mode 100644 templates/react-ts-starter/tsconfig.app.json create mode 100644 templates/react-ts-starter/tsconfig.node.json rename templates/react-ts-starter/{vite.config.js => vite.config.ts} (100%) diff --git a/templates/react-ts-starter/package.json b/templates/react-ts-starter/package.json index 1ad2dcc..ff1f4fe 100644 --- a/templates/react-ts-starter/package.json +++ b/templates/react-ts-starter/package.json @@ -5,7 +5,7 @@ "type": "module", "scripts": { "dev": "vite", - "build": "vite build", + "build": "tsc -b && vite build", "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0", "preview": "vite preview", "format": "prettier --write .", @@ -32,6 +32,8 @@ "postcss": "^8.4.49", "prettier": "^3.4.2", "tailwindcss": "^3.4.16", + "typescript": "^5.7.3", + "typescript-eslint": "^8.20.0", "vite": "^6.0.3", "vite-plugin-node-polyfills": "^0.22.0" }, diff --git a/templates/react-ts-starter/src/main.tsx b/templates/react-ts-starter/src/main.tsx index ccf6632..bef5202 100644 --- a/templates/react-ts-starter/src/main.tsx +++ b/templates/react-ts-starter/src/main.tsx @@ -1,10 +1,10 @@ import { StrictMode } from 'react' import { createRoot } from 'react-dom/client' -import App from './App' import './index.css' +import App from './App.tsx' -createRoot(document.getElementById('root')).render( +createRoot(document.getElementById('root')!).render( - + , ) diff --git a/templates/react-ts-starter/src/vite-env.d.ts b/templates/react-ts-starter/src/vite-env.d.ts new file mode 100644 index 0000000..11f02fe --- /dev/null +++ b/templates/react-ts-starter/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/templates/react-ts-starter/tsconfig.app.json b/templates/react-ts-starter/tsconfig.app.json new file mode 100644 index 0000000..358ca9b --- /dev/null +++ b/templates/react-ts-starter/tsconfig.app.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "isolatedModules": true, + "moduleDetection": "force", + "noEmit": true, + "jsx": "react-jsx", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true + }, + "include": ["src"] +} diff --git a/templates/react-ts-starter/tsconfig.json b/templates/react-ts-starter/tsconfig.json index a224293..1ffef60 100644 --- a/templates/react-ts-starter/tsconfig.json +++ b/templates/react-ts-starter/tsconfig.json @@ -1,5 +1,7 @@ { - "compilerOptions": { - "jsx": "react-jsx" - } + "files": [], + "references": [ + { "path": "./tsconfig.app.json" }, + { "path": "./tsconfig.node.json" } + ] } diff --git a/templates/react-ts-starter/tsconfig.node.json b/templates/react-ts-starter/tsconfig.node.json new file mode 100644 index 0000000..db0becc --- /dev/null +++ b/templates/react-ts-starter/tsconfig.node.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", + "target": "ES2022", + "lib": ["ES2023"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "isolatedModules": true, + "moduleDetection": "force", + "noEmit": true, + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/templates/react-ts-starter/vite.config.js b/templates/react-ts-starter/vite.config.ts similarity index 100% rename from templates/react-ts-starter/vite.config.js rename to templates/react-ts-starter/vite.config.ts From 1fffef15e5cff3b72f4e6daf9c47e5eac528d647 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Mon, 13 Jan 2025 21:23:46 +0100 Subject: [PATCH 2/2] feat: ts --- .../react-ts-starter/{juno.dev.config.js => juno.dev.config.ts} | 1 - 1 file changed, 1 deletion(-) rename templates/react-ts-starter/{juno.dev.config.js => juno.dev.config.ts} (75%) diff --git a/templates/react-ts-starter/juno.dev.config.js b/templates/react-ts-starter/juno.dev.config.ts similarity index 75% rename from templates/react-ts-starter/juno.dev.config.js rename to templates/react-ts-starter/juno.dev.config.ts index a985e4d..55e369d 100644 --- a/templates/react-ts-starter/juno.dev.config.js +++ b/templates/react-ts-starter/juno.dev.config.ts @@ -1,6 +1,5 @@ import {defineDevConfig} from '@junobuild/config'; -/** @type {import('@junobuild/config').JunoDevConfig} */ export default defineDevConfig(() => ({ satellite: { collections: {