From 535016d46a50f4fd5cae77d932aae2a6737d07ae Mon Sep 17 00:00:00 2001 From: Princesseuh Date: Mon, 24 Jul 2023 16:56:37 +0200 Subject: [PATCH 1/4] feat: update tsconfig presets for TypeScript 5.0 --- packages/astro/tsconfigs/base.json | 9 +++------ packages/astro/tsconfigs/strict.json | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/astro/tsconfigs/base.json b/packages/astro/tsconfigs/base.json index aa1f1754353a8..07033fffec011 100644 --- a/packages/astro/tsconfigs/base.json +++ b/packages/astro/tsconfigs/base.json @@ -5,11 +5,11 @@ "target": "ESNext", "module": "ESNext", // Enable node-style module resolution, for things like npm package imports. - "moduleResolution": "node", + "moduleResolution": "Bundler", + // Allow importing TypeScript files using their native extension (.ts(x)). + "allowImportingTsExtensions": true, // Enable JSON imports. "resolveJsonModule": true, - // Enable stricter transpilation for better output. - "isolatedModules": true, // Astro directly run TypeScript code, no transpilation needed. "noEmit": true, // Report an error when importing a file using a casing different from the casing on disk. @@ -23,9 +23,6 @@ "paths": { "~/assets/*": ["src/assets/*"] }, - // TypeScript 5.0 changed how `isolatedModules` and `importsNotUsedAsValues` works, deprecating the later - // Until the majority of users are on TypeScript 5.0, we'll have to supress those deprecation errors - "ignoreDeprecations": "5.0", // Allow JavaScript files to be imported "allowJs": true } diff --git a/packages/astro/tsconfigs/strict.json b/packages/astro/tsconfigs/strict.json index bc87a68e068b6..36f1b5ff2d507 100644 --- a/packages/astro/tsconfigs/strict.json +++ b/packages/astro/tsconfigs/strict.json @@ -3,7 +3,7 @@ "extends": "./base.json", "compilerOptions": { "strict": true, - // Error when a value import is only used as a type. - "importsNotUsedAsValues": "error" + // Enforce the usage of type-only imports when needed, which helps avoiding bundling issues. + "verbatimModuleSyntax": true } } From 72ee095a00ee29c909b9f34705eed5eb1cfc5e64 Mon Sep 17 00:00:00 2001 From: Princesseuh Date: Mon, 24 Jul 2023 17:00:07 +0200 Subject: [PATCH 2/4] chore: changeset --- .changeset/three-adults-exist.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/three-adults-exist.md diff --git a/.changeset/three-adults-exist.md b/.changeset/three-adults-exist.md new file mode 100644 index 0000000000000..f73b3624dcb73 --- /dev/null +++ b/.changeset/three-adults-exist.md @@ -0,0 +1,5 @@ +--- +'astro': major +--- + +Update `tsconfig.json` presets with `moduleResolution: 'bundler'` and other new options from TypeScript 5.0. Astro now assumes that you use TypeScript 5.0 (March 2023), or that your editor includes it, ex: VS Code 1.77 From c910d41946816f5041b16b20683fe827c666fcfd Mon Sep 17 00:00:00 2001 From: Princesseuh Date: Tue, 25 Jul 2023 11:16:15 +0200 Subject: [PATCH 3/4] config(tsconfig): Add verbatimModuleSyntax to base, figured it'll help people avoid weird bundling issues and save people time. --- packages/astro/tsconfigs/base.json | 6 +++++- packages/astro/tsconfigs/strict.json | 5 ++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/astro/tsconfigs/base.json b/packages/astro/tsconfigs/base.json index 07033fffec011..d73dccdba2fe5 100644 --- a/packages/astro/tsconfigs/base.json +++ b/packages/astro/tsconfigs/base.json @@ -10,9 +10,13 @@ "allowImportingTsExtensions": true, // Enable JSON imports. "resolveJsonModule": true, + // Enforce the usage of type-only imports when needed, which helps avoiding bundling issues. + "verbatimModuleSyntax": true, + // Ensure that each file can be transpiled without relying on other imports. + "isolatedModules": true, // Astro directly run TypeScript code, no transpilation needed. "noEmit": true, - // Report an error when importing a file using a casing different from the casing on disk. + // Report an error when importing a file using a casing different from another import of the same file. "forceConsistentCasingInFileNames": true, // Properly support importing CJS modules in ESM "esModuleInterop": true, diff --git a/packages/astro/tsconfigs/strict.json b/packages/astro/tsconfigs/strict.json index 36f1b5ff2d507..3064440a5d41a 100644 --- a/packages/astro/tsconfigs/strict.json +++ b/packages/astro/tsconfigs/strict.json @@ -2,8 +2,7 @@ "$schema": "https://json.schemastore.org/tsconfig", "extends": "./base.json", "compilerOptions": { - "strict": true, - // Enforce the usage of type-only imports when needed, which helps avoiding bundling issues. - "verbatimModuleSyntax": true + // Enable strict mode. This enables a few options at a time, see https://www.typescriptlang.org/tsconfig#strict for a list. + "strict": true } } From a956e4ea90dc863ba3656b065203d1e2ba64c532 Mon Sep 17 00:00:00 2001 From: Princesseuh Date: Tue, 25 Jul 2023 12:25:54 +0200 Subject: [PATCH 4/4] config: add comment explaining redudant option --- packages/astro/tsconfigs/base.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/astro/tsconfigs/base.json b/packages/astro/tsconfigs/base.json index d73dccdba2fe5..d921ef4bef6ef 100644 --- a/packages/astro/tsconfigs/base.json +++ b/packages/astro/tsconfigs/base.json @@ -13,6 +13,7 @@ // Enforce the usage of type-only imports when needed, which helps avoiding bundling issues. "verbatimModuleSyntax": true, // Ensure that each file can be transpiled without relying on other imports. + // This is redundant with the previous option, however it ensures that it's on even if someone disable `verbatimModuleSyntax` "isolatedModules": true, // Astro directly run TypeScript code, no transpilation needed. "noEmit": true,