diff --git a/.changeset/famous-apples-sleep.md b/.changeset/famous-apples-sleep.md new file mode 100644 index 00000000..1cb55bbd --- /dev/null +++ b/.changeset/famous-apples-sleep.md @@ -0,0 +1,5 @@ +--- +"@virtual-live-lab/tsconfig": patch +--- + +Add presets for experimental diff --git a/packages/tsconfig/README.md b/packages/tsconfig/README.md new file mode 100644 index 00000000..92dd86a1 --- /dev/null +++ b/packages/tsconfig/README.md @@ -0,0 +1,56 @@ + +# @virtual-live-lab/tsconfig + +![NPM Version](https://img.shields.io/npm/v/%40virtual-live-lab%2Ftsconfig) + +TypeScript configuration for Virtual Live Lab. + +## Presets + +- `astro`: Configuration for Astro. +- `base`: Basic configuration. +- `hono`: Configuration for Hono. +- `library`: Configuration for library. +- `nextjs`: Configuration for Next.js. +- `react`: Configuration for React. +- `remix`: Configuration for Remix. +- `vite`: Configuration for Vite. + +> [!WARNING] +> `library`, `react`, and `vite` preset is basically for internal use. + +## Installation + +### Use presets except Astro + +```json +// tsconfig.json +{ + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "@virtual-live-lab/tsconfig/{preset}", + // your configuration +} +``` + +### Use Astro preset + +```bash +npm install prettier \ + @virtual-live-lab/tsconfig \ + typescript \ + @astrojs/ts-plugin \ + --save-dev +``` + +```json +// tsconfig.json +{ + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "@virtual-live-lab/tsconfig/astro", + // your configuration +} +``` + +## License + +[MIT](https://choosealicense.com/licenses/mit/) diff --git a/packages/tsconfig/astro.json b/packages/tsconfig/astro.json new file mode 100644 index 00000000..4aaf7270 --- /dev/null +++ b/packages/tsconfig/astro.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "display": "Astro", + "extends": ["./base.json", "./vite.json"], + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "react", + // This plugin is required to import Astro from ts files outside VSCode. + "plugins": [ + { + "name": "@astrojs/ts-plugin" + } + ] + } +} diff --git a/packages/tsconfig/base.json b/packages/tsconfig/base.json index 3da9a4f8..5ae17af0 100644 --- a/packages/tsconfig/base.json +++ b/packages/tsconfig/base.json @@ -4,14 +4,15 @@ "esModuleInterop": true, "skipLibCheck": true, "target": "ES2022", + "lib": ["ES2023"], + "module": "Node16", + "moduleResolution": "Node16", "resolveJsonModule": true, "moduleDetection": "force", "isolatedModules": true, "strict": true, "forceConsistentCasingInFileNames": true, - "noUncheckedIndexedAccess": true, - "module": "ES2022", - "moduleResolution": "Bundler" + "noUncheckedIndexedAccess": true }, - "exclude": ["**/node_modules/**"] + "exclude": ["node_modules"] } diff --git a/packages/tsconfig/nextjs.json b/packages/tsconfig/nextjs.json index 44f42899..03c9ca25 100644 --- a/packages/tsconfig/nextjs.json +++ b/packages/tsconfig/nextjs.json @@ -1,13 +1,14 @@ { "$schema": "https://json.schemastore.org/tsconfig", "display": "Next.js", - "extends": "./base.json", + "extends": "./react.json", "compilerOptions": { - "plugins": [{ "name": "next" }], + "target": "ESNext", "module": "ESNext", "moduleResolution": "Bundler", - "allowJs": true, + "plugins": [{ "name": "next" }], "jsx": "preserve", "noEmit": true - } + }, + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"] } diff --git a/packages/tsconfig/react.json b/packages/tsconfig/react.json index c3a1b26f..24afefc7 100644 --- a/packages/tsconfig/react.json +++ b/packages/tsconfig/react.json @@ -1,7 +1,11 @@ { "$schema": "https://json.schemastore.org/tsconfig", + "display": "Base config for React", "extends": "./base.json", "compilerOptions": { + "module": "ESNext", + "target": "ESNext", + "lib": ["DOM", "DOM.Iterable", "ESNext"], "jsx": "react-jsx" } } diff --git a/packages/tsconfig/remix.json b/packages/tsconfig/remix.json new file mode 100644 index 00000000..7462453e --- /dev/null +++ b/packages/tsconfig/remix.json @@ -0,0 +1,13 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "display": "Remix", + "extends": ["./react.json", "./vite.json"], + "include": [ + "**/*.ts", + "**/*.tsx", + "**/.server/**/*.ts", + "**/.server/**/*.tsx", + "**/.client/**/*.ts", + "**/.client/**/*.tsx" + ] +} diff --git a/packages/tsconfig/vite.json b/packages/tsconfig/vite.json new file mode 100644 index 00000000..7ad77dba --- /dev/null +++ b/packages/tsconfig/vite.json @@ -0,0 +1,12 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "display": "Vite", + "compilerOptions": { + // https://vitejs.dev/guide/features.html#typescript-compiler-options + "useDefineForClassFields": true, + "target": "ESNext", + "module": "ESNext", + "moduleResolution": "Bundler", + "noEmit": true + } +}