diff --git a/.changeset/kind-hairs-report.md b/.changeset/kind-hairs-report.md new file mode 100644 index 000000000000..64565bd50923 --- /dev/null +++ b/.changeset/kind-hairs-report.md @@ -0,0 +1,5 @@ +--- +'astro': major +--- + +Changes TypeScript configuration - ([v6 upgrade guidance](https://v6.docs.astro.build/en/guides/upgrade-to/v6/#changed-typescript-configuration)) diff --git a/.github/scripts/bundle-size.mjs b/.github/scripts/bundle-size.mjs index ff36f3cbd778..c78f20fec6c4 100644 --- a/.github/scripts/bundle-size.mjs +++ b/.github/scripts/bundle-size.mjs @@ -75,7 +75,7 @@ async function bundle(files) { bundle: true, minify: true, sourcemap: false, - target: ['es2018'], + target: ['esnext'], outdir: 'out', external: ['astro:*', 'aria-query', 'axobject-query'], metafile: true, diff --git a/benchmark/packages/adapter/tsconfig.json b/benchmark/packages/adapter/tsconfig.json index 1504b4b6dfa4..7f8d5c4c2184 100644 --- a/benchmark/packages/adapter/tsconfig.json +++ b/benchmark/packages/adapter/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../../tsconfig.base.json", "include": ["src"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist" } } diff --git a/benchmark/packages/timer/tsconfig.json b/benchmark/packages/timer/tsconfig.json index 1504b4b6dfa4..7f8d5c4c2184 100644 --- a/benchmark/packages/timer/tsconfig.json +++ b/benchmark/packages/timer/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../../tsconfig.base.json", "include": ["src"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist" } } diff --git a/examples/portfolio/src/components/Nav.astro b/examples/portfolio/src/components/Nav.astro index d8fbd075c30f..88652f5763cd 100644 --- a/examples/portfolio/src/components/Nav.astro +++ b/examples/portfolio/src/components/Nav.astro @@ -124,7 +124,7 @@ const isCurrentPage = (href: string) => { }; // Toggle menu visibility when the menu button is clicked. - btn.addEventListener('click', () => setExpanded(menu.hidden)); + btn.addEventListener('click', () => setExpanded(menu.hidden === true)); // Hide menu button for large screens. const handleViewports = (e: MediaQueryList | MediaQueryListEvent) => { diff --git a/examples/toolbar-app/tsconfig.json b/examples/toolbar-app/tsconfig.json index 281fb7f925fa..0a393886f195 100644 --- a/examples/toolbar-app/tsconfig.json +++ b/examples/toolbar-app/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "astro/tsconfigs/strict", "compilerOptions": { - "outDir": "dist", - "rootDir": "src" + "outDir": "./dist", + "rootDir": "./src" } } diff --git a/packages/astro-prism/tsconfig.json b/packages/astro-prism/tsconfig.json index 18443cddf207..17e08031358c 100644 --- a/packages/astro-prism/tsconfig.json +++ b/packages/astro-prism/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.base.json", "include": ["src"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist" } } diff --git a/packages/astro-rss/tsconfig.json b/packages/astro-rss/tsconfig.json index 18443cddf207..17e08031358c 100644 --- a/packages/astro-rss/tsconfig.json +++ b/packages/astro-rss/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.base.json", "include": ["src"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist" } } diff --git a/packages/astro/src/vite-plugin-config-alias/README.md b/packages/astro/src/vite-plugin-config-alias/README.md index 3b470adeda33..765a00550c5c 100644 --- a/packages/astro/src/vite-plugin-config-alias/README.md +++ b/packages/astro/src/vite-plugin-config-alias/README.md @@ -7,9 +7,8 @@ Consider the following example configuration: ``` { "compilerOptions": { - "baseUrl": "src", "paths": { - "components:*": ["components/*.astro"] + "components:*": ["src/components/*.astro"] } } } diff --git a/packages/astro/test/fixtures/alias-tsconfig/tsconfig.json b/packages/astro/test/fixtures/alias-tsconfig/tsconfig.json index 31340063c1c6..a448e76fbc8f 100644 --- a/packages/astro/test/fixtures/alias-tsconfig/tsconfig.json +++ b/packages/astro/test/fixtures/alias-tsconfig/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + // TODO: remove when upgrading to TS 6 "baseUrl": ".", "paths": { "@components/*": [ diff --git a/packages/astro/test/fixtures/core-image-base/tsconfig.json b/packages/astro/test/fixtures/core-image-base/tsconfig.json index ff44eda8dc0e..1854f60e49c2 100644 --- a/packages/astro/test/fixtures/core-image-base/tsconfig.json +++ b/packages/astro/test/fixtures/core-image-base/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "astro/tsconfigs/strict", "compilerOptions": { - "baseUrl": ".", "paths": { "~/assets/*": [ "src/assets/*" diff --git a/packages/astro/test/fixtures/core-image-deletion/tsconfig.json b/packages/astro/test/fixtures/core-image-deletion/tsconfig.json index c193287fccd6..f79821518be8 100644 --- a/packages/astro/test/fixtures/core-image-deletion/tsconfig.json +++ b/packages/astro/test/fixtures/core-image-deletion/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "astro/tsconfigs/base", "compilerOptions": { - "baseUrl": ".", "paths": { "~/assets/*": ["src/assets/*"] }, diff --git a/packages/astro/test/fixtures/core-image-infersize/tsconfig.json b/packages/astro/test/fixtures/core-image-infersize/tsconfig.json index 2124752725b7..f11a46c8e5fb 100644 --- a/packages/astro/test/fixtures/core-image-infersize/tsconfig.json +++ b/packages/astro/test/fixtures/core-image-infersize/tsconfig.json @@ -1,8 +1,5 @@ { "extends": "astro/tsconfigs/base", - "compilerOptions": { - "baseUrl": ".", - }, "include": [".astro/types.d.ts", "**/*"], "exclude": ["dist"] } diff --git a/packages/astro/test/fixtures/core-image-layout/tsconfig.json b/packages/astro/test/fixtures/core-image-layout/tsconfig.json index c193287fccd6..f79821518be8 100644 --- a/packages/astro/test/fixtures/core-image-layout/tsconfig.json +++ b/packages/astro/test/fixtures/core-image-layout/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "astro/tsconfigs/base", "compilerOptions": { - "baseUrl": ".", "paths": { "~/assets/*": ["src/assets/*"] }, diff --git a/packages/astro/test/fixtures/core-image-picture-emit-file/tsconfig.json b/packages/astro/test/fixtures/core-image-picture-emit-file/tsconfig.json index ff44eda8dc0e..1854f60e49c2 100644 --- a/packages/astro/test/fixtures/core-image-picture-emit-file/tsconfig.json +++ b/packages/astro/test/fixtures/core-image-picture-emit-file/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "astro/tsconfigs/strict", "compilerOptions": { - "baseUrl": ".", "paths": { "~/assets/*": [ "src/assets/*" diff --git a/packages/astro/test/fixtures/core-image-remark-imgattr/tsconfig.json b/packages/astro/test/fixtures/core-image-remark-imgattr/tsconfig.json index 2124752725b7..f11a46c8e5fb 100644 --- a/packages/astro/test/fixtures/core-image-remark-imgattr/tsconfig.json +++ b/packages/astro/test/fixtures/core-image-remark-imgattr/tsconfig.json @@ -1,8 +1,5 @@ { "extends": "astro/tsconfigs/base", - "compilerOptions": { - "baseUrl": ".", - }, "include": [".astro/types.d.ts", "**/*"], "exclude": ["dist"] } diff --git a/packages/astro/test/fixtures/core-image-ssg/tsconfig.json b/packages/astro/test/fixtures/core-image-ssg/tsconfig.json index c193287fccd6..f79821518be8 100644 --- a/packages/astro/test/fixtures/core-image-ssg/tsconfig.json +++ b/packages/astro/test/fixtures/core-image-ssg/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "astro/tsconfigs/base", "compilerOptions": { - "baseUrl": ".", "paths": { "~/assets/*": ["src/assets/*"] }, diff --git a/packages/astro/test/fixtures/core-image-svg-optimized/tsconfig.json b/packages/astro/test/fixtures/core-image-svg-optimized/tsconfig.json index 923ed4e24fb7..51747eeb3102 100644 --- a/packages/astro/test/fixtures/core-image-svg-optimized/tsconfig.json +++ b/packages/astro/test/fixtures/core-image-svg-optimized/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "astro/tsconfigs/strict", "compilerOptions": { - "baseUrl": ".", "paths": { "~/assets/*": [ "src/assets/*" diff --git a/packages/astro/test/fixtures/core-image-svg/tsconfig.json b/packages/astro/test/fixtures/core-image-svg/tsconfig.json index 923ed4e24fb7..51747eeb3102 100644 --- a/packages/astro/test/fixtures/core-image-svg/tsconfig.json +++ b/packages/astro/test/fixtures/core-image-svg/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "astro/tsconfigs/strict", "compilerOptions": { - "baseUrl": ".", "paths": { "~/assets/*": [ "src/assets/*" diff --git a/packages/astro/test/fixtures/core-image-unconventional-settings/tsconfig.json b/packages/astro/test/fixtures/core-image-unconventional-settings/tsconfig.json index c193287fccd6..f79821518be8 100644 --- a/packages/astro/test/fixtures/core-image-unconventional-settings/tsconfig.json +++ b/packages/astro/test/fixtures/core-image-unconventional-settings/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "astro/tsconfigs/base", "compilerOptions": { - "baseUrl": ".", "paths": { "~/assets/*": ["src/assets/*"] }, diff --git a/packages/astro/test/fixtures/core-image/tsconfig.json b/packages/astro/test/fixtures/core-image/tsconfig.json index ff44eda8dc0e..1854f60e49c2 100644 --- a/packages/astro/test/fixtures/core-image/tsconfig.json +++ b/packages/astro/test/fixtures/core-image/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "astro/tsconfigs/strict", "compilerOptions": { - "baseUrl": ".", "paths": { "~/assets/*": [ "src/assets/*" diff --git a/packages/astro/test/fixtures/custom-renderer/tsconfig.json b/packages/astro/test/fixtures/custom-renderer/tsconfig.json index f1ad59fe06c3..fe4fe0892c95 100644 --- a/packages/astro/test/fixtures/custom-renderer/tsconfig.json +++ b/packages/astro/test/fixtures/custom-renderer/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "astro/tsconfigs/base", "compilerOptions": { - "baseUrl": ".", "paths": { "@custom-renderer/*": ["src/custom-renderer/*"] }, diff --git a/packages/astro/test/fixtures/svg-deduplication/tsconfig.json b/packages/astro/test/fixtures/svg-deduplication/tsconfig.json index a1269dab909f..ab8e2d451686 100644 --- a/packages/astro/test/fixtures/svg-deduplication/tsconfig.json +++ b/packages/astro/test/fixtures/svg-deduplication/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "../../../tsconfigs/strictest.json", "compilerOptions": { - "baseUrl": ".", "paths": { "~/*": ["./src/*"] } diff --git a/packages/astro/tsconfigs/base.json b/packages/astro/tsconfigs/base.json index 55adf57bb5e4..1c667f933a8b 100644 --- a/packages/astro/tsconfigs/base.json +++ b/packages/astro/tsconfigs/base.json @@ -26,7 +26,9 @@ // Allow JavaScript files to be imported "allowJs": true, // Allow JSX files (or files that are internally considered JSX, like Astro files) to be imported inside `.js` and `.ts` files. - "jsx": "preserve" + "jsx": "preserve", + "types": ["node"], + "libReplacement": false }, "exclude": ["${configDir}/dist"], "include": ["${configDir}/.astro/types.d.ts", "${configDir}/**/*"] diff --git a/packages/create-astro/tsconfig.json b/packages/create-astro/tsconfig.json index 18443cddf207..17e08031358c 100644 --- a/packages/create-astro/tsconfig.json +++ b/packages/create-astro/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.base.json", "include": ["src"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist" } } diff --git a/packages/db/tsconfig.json b/packages/db/tsconfig.json index 7592ad8a1774..de415b5be4ad 100644 --- a/packages/db/tsconfig.json +++ b/packages/db/tsconfig.json @@ -3,6 +3,7 @@ "include": ["src"], "exclude": ["src/runtime/virtual.ts"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist" } } diff --git a/packages/db/tsconfig.virtual.json b/packages/db/tsconfig.virtual.json index 41d2aef4a11b..f23230d26235 100644 --- a/packages/db/tsconfig.virtual.json +++ b/packages/db/tsconfig.virtual.json @@ -7,6 +7,7 @@ "extends": "../../tsconfig.base.json", "files": ["./src/runtime/virtual.ts"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist/_internal" } } diff --git a/packages/integrations/alpinejs/tsconfig.json b/packages/integrations/alpinejs/tsconfig.json index 1504b4b6dfa4..7f8d5c4c2184 100644 --- a/packages/integrations/alpinejs/tsconfig.json +++ b/packages/integrations/alpinejs/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../../tsconfig.base.json", "include": ["src"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist" } } diff --git a/packages/integrations/cloudflare/tsconfig.json b/packages/integrations/cloudflare/tsconfig.json index 555bd5e4145b..cc4ec75d8fbc 100644 --- a/packages/integrations/cloudflare/tsconfig.json +++ b/packages/integrations/cloudflare/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../../tsconfig.base.json", "include": ["src", "virtual.d.ts", "types.d.ts"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist" } } diff --git a/packages/integrations/markdoc/test/fixtures/image-assets-custom/tsconfig.json b/packages/integrations/markdoc/test/fixtures/image-assets-custom/tsconfig.json index c193287fccd6..f79821518be8 100644 --- a/packages/integrations/markdoc/test/fixtures/image-assets-custom/tsconfig.json +++ b/packages/integrations/markdoc/test/fixtures/image-assets-custom/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "astro/tsconfigs/base", "compilerOptions": { - "baseUrl": ".", "paths": { "~/assets/*": ["src/assets/*"] }, diff --git a/packages/integrations/markdoc/test/fixtures/image-assets/tsconfig.json b/packages/integrations/markdoc/test/fixtures/image-assets/tsconfig.json index c193287fccd6..f79821518be8 100644 --- a/packages/integrations/markdoc/test/fixtures/image-assets/tsconfig.json +++ b/packages/integrations/markdoc/test/fixtures/image-assets/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "astro/tsconfigs/base", "compilerOptions": { - "baseUrl": ".", "paths": { "~/assets/*": ["src/assets/*"] }, diff --git a/packages/integrations/markdoc/tsconfig.json b/packages/integrations/markdoc/tsconfig.json index 1504b4b6dfa4..7f8d5c4c2184 100644 --- a/packages/integrations/markdoc/tsconfig.json +++ b/packages/integrations/markdoc/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../../tsconfig.base.json", "include": ["src"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist" } } diff --git a/packages/integrations/mdx/test/fixtures/mdx-images/src/pages/content-collection.astro b/packages/integrations/mdx/test/fixtures/mdx-images/src/pages/content-collection.astro index 68a3fe3baba5..444a90cf53c9 100644 --- a/packages/integrations/mdx/test/fixtures/mdx-images/src/pages/content-collection.astro +++ b/packages/integrations/mdx/test/fixtures/mdx-images/src/pages/content-collection.astro @@ -1,6 +1,6 @@ --- import { getEntry, render } from 'astro:content'; -import MyImage from 'src/components/MyImage.astro'; +import MyImage from '../components/MyImage.astro'; const entry = await getEntry('blog', 'entry'); const { Content } = await render(entry) diff --git a/packages/integrations/mdx/test/fixtures/mdx-images/src/pages/esm-import.astro b/packages/integrations/mdx/test/fixtures/mdx-images/src/pages/esm-import.astro index 4e4db66a4d17..c250d50ba203 100644 --- a/packages/integrations/mdx/test/fixtures/mdx-images/src/pages/esm-import.astro +++ b/packages/integrations/mdx/test/fixtures/mdx-images/src/pages/esm-import.astro @@ -1,5 +1,5 @@ --- -import MyImage from 'src/components/MyImage.astro'; +import MyImage from '../components/MyImage.astro'; import MDX from '../components/Component.mdx'; --- diff --git a/packages/integrations/mdx/test/fixtures/mdx-images/tsconfig.json b/packages/integrations/mdx/test/fixtures/mdx-images/tsconfig.json index c193287fccd6..f79821518be8 100644 --- a/packages/integrations/mdx/test/fixtures/mdx-images/tsconfig.json +++ b/packages/integrations/mdx/test/fixtures/mdx-images/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "astro/tsconfigs/base", "compilerOptions": { - "baseUrl": ".", "paths": { "~/assets/*": ["src/assets/*"] }, diff --git a/packages/integrations/mdx/tsconfig.json b/packages/integrations/mdx/tsconfig.json index 1504b4b6dfa4..7f8d5c4c2184 100644 --- a/packages/integrations/mdx/tsconfig.json +++ b/packages/integrations/mdx/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../../tsconfig.base.json", "include": ["src"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist" } } diff --git a/packages/integrations/netlify/tsconfig.json b/packages/integrations/netlify/tsconfig.json index ea1c17c2952b..8b6303c6d76d 100644 --- a/packages/integrations/netlify/tsconfig.json +++ b/packages/integrations/netlify/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../../tsconfig.base.json", "include": ["src", "virtual.d.ts"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist" } } diff --git a/packages/integrations/node/tsconfig.json b/packages/integrations/node/tsconfig.json index ea1c17c2952b..8b6303c6d76d 100644 --- a/packages/integrations/node/tsconfig.json +++ b/packages/integrations/node/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../../tsconfig.base.json", "include": ["src", "virtual.d.ts"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist" } } diff --git a/packages/integrations/partytown/tsconfig.json b/packages/integrations/partytown/tsconfig.json index 1504b4b6dfa4..7f8d5c4c2184 100644 --- a/packages/integrations/partytown/tsconfig.json +++ b/packages/integrations/partytown/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../../tsconfig.base.json", "include": ["src"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist" } } diff --git a/packages/integrations/preact/tsconfig.json b/packages/integrations/preact/tsconfig.json index 1504b4b6dfa4..7f8d5c4c2184 100644 --- a/packages/integrations/preact/tsconfig.json +++ b/packages/integrations/preact/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../../tsconfig.base.json", "include": ["src"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist" } } diff --git a/packages/integrations/react/tsconfig.json b/packages/integrations/react/tsconfig.json index c152f18f8f55..c72c8035a4ba 100644 --- a/packages/integrations/react/tsconfig.json +++ b/packages/integrations/react/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../../tsconfig.base.json", "include": ["src", "env.d.ts"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist" } } diff --git a/packages/integrations/sitemap/tsconfig.json b/packages/integrations/sitemap/tsconfig.json index 1504b4b6dfa4..7f8d5c4c2184 100644 --- a/packages/integrations/sitemap/tsconfig.json +++ b/packages/integrations/sitemap/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../../tsconfig.base.json", "include": ["src"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist" } } diff --git a/packages/integrations/solid/tsconfig.json b/packages/integrations/solid/tsconfig.json index 1504b4b6dfa4..7f8d5c4c2184 100644 --- a/packages/integrations/solid/tsconfig.json +++ b/packages/integrations/solid/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../../tsconfig.base.json", "include": ["src"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist" } } diff --git a/packages/integrations/svelte/tsconfig.json b/packages/integrations/svelte/tsconfig.json index 5742d1f6efd2..cf99770081ac 100644 --- a/packages/integrations/svelte/tsconfig.json +++ b/packages/integrations/svelte/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../../tsconfig.base.json", "include": ["src"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist", "verbatimModuleSyntax": false } diff --git a/packages/integrations/vercel/tsconfig.json b/packages/integrations/vercel/tsconfig.json index ea1c17c2952b..8b6303c6d76d 100644 --- a/packages/integrations/vercel/tsconfig.json +++ b/packages/integrations/vercel/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../../tsconfig.base.json", "include": ["src", "virtual.d.ts"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist" } } diff --git a/packages/integrations/vue/tsconfig.json b/packages/integrations/vue/tsconfig.json index 100f3c93b6d7..346a8461206c 100644 --- a/packages/integrations/vue/tsconfig.json +++ b/packages/integrations/vue/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../../tsconfig.base.json", "include": ["src", "env.d.ts"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist", "verbatimModuleSyntax": false } diff --git a/packages/internal-helpers/tsconfig.json b/packages/internal-helpers/tsconfig.json index 18443cddf207..17e08031358c 100644 --- a/packages/internal-helpers/tsconfig.json +++ b/packages/internal-helpers/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.base.json", "include": ["src"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist" } } diff --git a/packages/language-tools/astro-check/tsconfig.json b/packages/language-tools/astro-check/tsconfig.json index 99f2d27ea436..7c2d5f06b897 100644 --- a/packages/language-tools/astro-check/tsconfig.json +++ b/packages/language-tools/astro-check/tsconfig.json @@ -1,8 +1,8 @@ { "extends": "../tsconfig.json", "compilerOptions": { - "rootDir": "src", - "outDir": "dist", + "rootDir": "./src", + "outDir": "./dist", "emitDeclarationOnly": false, "sourceMap": true, "module": "ES2022", diff --git a/packages/language-tools/language-server/src/core/compilerUtils.ts b/packages/language-tools/language-server/src/core/compilerUtils.ts deleted file mode 100644 index 3bc0a2dead3d..000000000000 --- a/packages/language-tools/language-server/src/core/compilerUtils.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { AttributeNode, Point } from '@astrojs/compiler'; -import { Position as LSPPosition } from '@volar/language-server'; - -/** - * Transform a Point from the Astro compiler to an LSP Position - */ -export function PointToPosition(point: Point) { - // Columns and lines are 0-based in LSP, but the compiler's Point are 1 based. - return LSPPosition.create(point.line - 1, point.column - 1); -} - -type WithRequired = T & { [P in K]-?: T[P] }; -export type AttributeNodeWithPosition = WithRequired; diff --git a/packages/language-tools/language-server/test/units/utils.test.ts b/packages/language-tools/language-server/test/units/utils.test.ts index 3fdbd46a79ae..9ba81a001c7f 100644 --- a/packages/language-tools/language-server/test/units/utils.test.ts +++ b/packages/language-tools/language-server/test/units/utils.test.ts @@ -1,11 +1,9 @@ import assert from 'node:assert'; import { describe, it } from 'node:test'; -import type { Point } from '@astrojs/compiler/types.js'; import { Range } from '@volar/language-server'; import type { Node } from 'vscode-html-languageservice'; import * as html from 'vscode-html-languageservice'; import { getTSXRangesAsLSPRanges, safeConvertToTSX } from '../../dist/core/astro2tsx.js'; -import * as compilerUtils from '../../dist/core/compilerUtils.js'; import { getAstroMetadata } from '../../dist/core/parseAstro.js'; import * as utils from '../../dist/plugins/utils.js'; @@ -64,18 +62,6 @@ describe('Utilities', async () => { assert.strictEqual(utils.isInsideFrontmatter(6, openFrontmatter.frontmatter), true); }); - it('PointToPosition - properly transform a Point from the Astro compiler to an LSP Position', () => { - const point: Point = { - line: 1, - column: 2, - offset: 3, - }; - assert.deepStrictEqual(compilerUtils.PointToPosition(point), { - line: 0, - character: 1, - }); - }); - it('ensureRangeIsInFrontmatter - properly return a range inside the frontmatter', () => { const beforeFrontmatterRange = Range.create(0, 0, 0, 0); const input = '---\nfoo\n---\n'; diff --git a/packages/language-tools/language-server/tsconfig.json b/packages/language-tools/language-server/tsconfig.json index 029f1c7f6a9e..2b5c5fb560b6 100644 --- a/packages/language-tools/language-server/tsconfig.json +++ b/packages/language-tools/language-server/tsconfig.json @@ -1,8 +1,8 @@ { "extends": "../tsconfig.json", "compilerOptions": { - "outDir": "dist", - "rootDir": "src", + "outDir": "./dist", + "rootDir": "./src", "emitDeclarationOnly": false, "sourceMap": true }, diff --git a/packages/language-tools/ts-plugin/tsconfig.json b/packages/language-tools/ts-plugin/tsconfig.json index 15bae86fc5f0..90eb9eaaad2b 100644 --- a/packages/language-tools/ts-plugin/tsconfig.json +++ b/packages/language-tools/ts-plugin/tsconfig.json @@ -1,12 +1,9 @@ { "extends": "../tsconfig.json", "compilerOptions": { - "outDir": "dist", - "rootDir": "src", - "target": "ES2020", - "module": "CommonJS", - "emitDeclarationOnly": false, - "ignoreDeprecations": "5.0" + "outDir": "./dist", + "rootDir": "./src", + "emitDeclarationOnly": false }, "include": ["src"], "exclude": ["node_modules"] diff --git a/packages/language-tools/tsconfig.json b/packages/language-tools/tsconfig.json index 9e965c52c3c8..83a96ac9ee32 100644 --- a/packages/language-tools/tsconfig.json +++ b/packages/language-tools/tsconfig.json @@ -3,6 +3,7 @@ "target": "ES2021", "lib": ["WebWorker", "ES2021"], "module": "commonjs", + // TODO: when upgrading to TS 6, will need to be set to "bundler" "moduleResolution": "node", "declaration": true, "emitDeclarationOnly": true, diff --git a/packages/language-tools/vscode/tsconfig.json b/packages/language-tools/vscode/tsconfig.json index 6e3b3eca1868..523b94dc4b99 100644 --- a/packages/language-tools/vscode/tsconfig.json +++ b/packages/language-tools/vscode/tsconfig.json @@ -1,9 +1,10 @@ { "extends": "../tsconfig.json", "compilerOptions": { - "outDir": "dist", + "rootDir": "./src", + "outDir": "./dist", "emitDeclarationOnly": true, "checkJs": true }, - "include": ["src", ".vscode-test.js"] + "include": ["src"] } diff --git a/packages/language-tools/yaml2ts/tsconfig.json b/packages/language-tools/yaml2ts/tsconfig.json index 029f1c7f6a9e..2b5c5fb560b6 100644 --- a/packages/language-tools/yaml2ts/tsconfig.json +++ b/packages/language-tools/yaml2ts/tsconfig.json @@ -1,8 +1,8 @@ { "extends": "../tsconfig.json", "compilerOptions": { - "outDir": "dist", - "rootDir": "src", + "outDir": "./dist", + "rootDir": "./src", "emitDeclarationOnly": false, "sourceMap": true }, diff --git a/packages/telemetry/tsconfig.json b/packages/telemetry/tsconfig.json index 18443cddf207..17e08031358c 100644 --- a/packages/telemetry/tsconfig.json +++ b/packages/telemetry/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.base.json", "include": ["src"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist" } } diff --git a/packages/underscore-redirects/tsconfig.json b/packages/underscore-redirects/tsconfig.json index 18443cddf207..17e08031358c 100644 --- a/packages/underscore-redirects/tsconfig.json +++ b/packages/underscore-redirects/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.base.json", "include": ["src"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist" } } diff --git a/packages/upgrade/tsconfig.json b/packages/upgrade/tsconfig.json index d15ade00ff80..2341647f4266 100644 --- a/packages/upgrade/tsconfig.json +++ b/packages/upgrade/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.base.json", "include": ["src", "index.d.ts"], "compilerOptions": { + "rootDir": "./src", "allowJs": true, "emitDeclarationOnly": false, "noEmit": true, diff --git a/scripts/jsconfig.json b/scripts/jsconfig.json index 5cf3835e818d..0caa704a7a8e 100644 --- a/scripts/jsconfig.json +++ b/scripts/jsconfig.json @@ -3,7 +3,7 @@ "declaration": true, "strict": true, "module": "esnext", - "moduleResolution": "node", + "moduleResolution": "nodenext", "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, diff --git a/tsconfig.base.json b/tsconfig.base.json index 432d3c35380d..7ed082d83639 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -4,14 +4,15 @@ "declaration": true, "emitDeclarationOnly": true, "strict": true, - "moduleResolution": "Node16", - "target": "ES2022", - "module": "Node16", + "moduleResolution": "nodenext", + "target": "esnext", + "module": "nodenext", "esModuleInterop": true, "skipLibCheck": true, "verbatimModuleSyntax": true, "stripInternal": true, "noUnusedLocals": true, - "noUnusedParameters": true + "noUnusedParameters": true, + "types": ["node"] } }