astro
> TypeScript configuration for Astro projects with JSX preserve mode and bundler resolution. Extends @jmlweb/tsconfig-base.
โจ Features
Section titled โโจ Featuresโ- ๐ Astro Ready:
jsx: "preserve"for Astro and framework components - ๐ DOM Types:
DOMandDOM.Iterablelibs - ๐ฆ Bundler Resolution:
module: "ESNext"withmoduleResolution: "bundler" - ๐ Strict Mode: inherits every strict flag from the base config
๐ฆ Installation
Section titled โ๐ฆ Installationโnpm install --save-dev @jmlweb/tsconfig-astro @jmlweb/tsconfig-base astro typescript๐ Quick Start
Section titled โ๐ Quick Startโ{ "extends": "@jmlweb/tsconfig-astro", "include": ["src", ".astro/types.d.ts"], "exclude": ["node_modules", "dist"]}๐ก Examples
Section titled โ๐ก ExamplesโPath aliases
Section titled โPath aliasesโ{ "extends": "@jmlweb/tsconfig-astro", "compilerOptions": { "paths": { "@/*": ["./src/*"] } }, "include": ["src", ".astro/types.d.ts"]}React islands
Section titled โReact islandsโ{ "extends": "@jmlweb/tsconfig-astro", "compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "react" }, "include": ["src", ".astro/types.d.ts"]}๐ Configuration Details
Section titled โ๐ Configuration DetailsโExtends @jmlweb/tsconfig-base and overrides:
| Option | Value | Description |
|---|---|---|
jsx |
preserve |
Leave JSX to Astro and its renderers |
module |
ESNext |
ES modules for bundlers |
moduleResolution |
bundler |
Bundler-style resolution |
lib |
["ES2022", "DOM", "DOM.Iterable"] |
ES2022 plus browser APIs |
Everything else (strict, target: ES2022, verbatimModuleSyntax, โฆ) comes from the base config.
๐ฏ When to Use
Section titled โ๐ฏ When to Useโ- โ Astro sites and content-driven projects
- โ Astro with React, Preact or Solid islands
Use @jmlweb/tsconfig-react for React-only apps and @jmlweb/tsconfig-node for Node.js code.
๐ง Extending the Configuration
Section titled โ๐ง Extending the Configurationโ{ "extends": "@jmlweb/tsconfig-astro", "compilerOptions": { "noEmit": true, "types": ["astro/client"] }}๐ Usage with Scripts
Section titled โ๐ Usage with Scriptsโ{ "scripts": { "dev": "astro dev", "build": "astro check && astro build", "typecheck": "astro check" }}npm run typecheckastro check requires @astrojs/check.
๐ Requirements
Section titled โ๐ Requirementsโ- Node.js >= 22.12.0
- TypeScript >= 5.0.0
- Astro >= 4.0.0
๐ฆ Peer Dependencies
Section titled โ๐ฆ Peer Dependenciesโ@jmlweb/tsconfig-base(^2.0.0)astro(>=4.0.0)typescript(>=5.0.0)
๐ Related Packages
Section titled โ๐ Related Packagesโ@jmlweb/tsconfig-base- base config extended by this package@jmlweb/eslint-config-astro- ESLint configuration for Astro@jmlweb/oxfmt-config-base- Oxfmt configuration (recommended)
๐ Migration Guide
Section titled โ๐ Migration Guideโ1.x โ 2.0.0
Section titled โ1.x โ 2.0.0โBreaking: Node.js >=22.12.0 is now required (Node.js 18 and 20 are end-of-life).
- Upgrade Node.js to 22.12.0 or later.
- Update the package:
npm install --save-dev @jmlweb/tsconfig-astro@^2.0.0.
The compilerOptions are unchanged. See the Changelog.
๐ License
Section titled โ๐ LicenseโMIT