Skip to content

Commit

Permalink
Update tsconfig.json presets for TS 5.0 (#7785)
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh authored and ematipico committed Aug 3, 2023
1 parent 78de801 commit 1be84df
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/three-adults-exist.md
Original file line number Diff line number Diff line change
@@ -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
14 changes: 8 additions & 6 deletions packages/astro/tsconfigs/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@
"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.
// 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,
// 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,
Expand All @@ -23,9 +28,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
}
Expand Down
5 changes: 2 additions & 3 deletions packages/astro/tsconfigs/strict.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./base.json",
"compilerOptions": {
"strict": true,
// Error when a value import is only used as a type.
"importsNotUsedAsValues": "error"
// Enable strict mode. This enables a few options at a time, see https://www.typescriptlang.org/tsconfig#strict for a list.
"strict": true
}
}

0 comments on commit 1be84df

Please sign in to comment.