Skip to content

Commit 96beb88

Browse files
Princesseuhematipico
authored andcommitted
Update tsconfig.json presets for TS 5.0 (#7785)
1 parent 0f06255 commit 96beb88

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

.changeset/three-adults-exist.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': major
3+
---
4+
5+
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

packages/astro/tsconfigs/base.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55
"target": "ESNext",
66
"module": "ESNext",
77
// Enable node-style module resolution, for things like npm package imports.
8-
"moduleResolution": "node",
8+
"moduleResolution": "Bundler",
9+
// Allow importing TypeScript files using their native extension (.ts(x)).
10+
"allowImportingTsExtensions": true,
911
// Enable JSON imports.
1012
"resolveJsonModule": true,
11-
// Enable stricter transpilation for better output.
13+
// Enforce the usage of type-only imports when needed, which helps avoiding bundling issues.
14+
"verbatimModuleSyntax": true,
15+
// Ensure that each file can be transpiled without relying on other imports.
16+
// This is redundant with the previous option, however it ensures that it's on even if someone disable `verbatimModuleSyntax`
1217
"isolatedModules": true,
1318
// Astro directly run TypeScript code, no transpilation needed.
1419
"noEmit": true,
15-
// Report an error when importing a file using a casing different from the casing on disk.
20+
// Report an error when importing a file using a casing different from another import of the same file.
1621
"forceConsistentCasingInFileNames": true,
1722
// Properly support importing CJS modules in ESM
1823
"esModuleInterop": true,
@@ -23,9 +28,6 @@
2328
"paths": {
2429
"~/assets/*": ["src/assets/*"]
2530
},
26-
// TypeScript 5.0 changed how `isolatedModules` and `importsNotUsedAsValues` works, deprecating the later
27-
// Until the majority of users are on TypeScript 5.0, we'll have to supress those deprecation errors
28-
"ignoreDeprecations": "5.0",
2931
// Allow JavaScript files to be imported
3032
"allowJs": true
3133
}

packages/astro/tsconfigs/strict.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
"$schema": "https://json.schemastore.org/tsconfig",
33
"extends": "./base.json",
44
"compilerOptions": {
5-
"strict": true,
6-
// Error when a value import is only used as a type.
7-
"importsNotUsedAsValues": "error"
5+
// Enable strict mode. This enables a few options at a time, see https://www.typescriptlang.org/tsconfig#strict for a list.
6+
"strict": true
87
}
98
}

0 commit comments

Comments
 (0)