@nuxt/docs-nightly 5.0.0-29732357.e9b11064 → 5.0.0-29732421.92bcb2f1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -63,6 +63,7 @@ When you set your `future.compatibilityVersion` to `5`, defaults throughout your
|
|
|
63
63
|
- **`clearNuxtState` resets to defaults**: `clearNuxtState` will [reset state to its initial value](/docs/4.x/getting-started/upgrade#respect-defaults-when-clearing-usestate) instead of setting it to `undefined`
|
|
64
64
|
- **Non-async `callHook`**: [`callHook` may return `void`](/docs/4.x/getting-started/upgrade#non-async-callhook) instead of always returning a `Promise`
|
|
65
65
|
- **Comment node placeholders**: Client-only components use [comment nodes instead of `<div>`](/docs/4.x/getting-started/upgrade#client-only-comment-placeholders) as SSR placeholders, fixing a scoped styles hydration issue
|
|
66
|
+
- **Stricter side-effect imports**: The generated `tsconfig.json` enables [`noUncheckedSideEffectImports`](/docs/4.x/getting-started/upgrade#stricter-side-effect-imports) to match the TypeScript 7 default
|
|
66
67
|
- Other Nuxt 5 improvements and changes as they become available
|
|
67
68
|
|
|
68
69
|
::note
|
|
@@ -524,3 +525,43 @@ export default defineNuxtConfig({
|
|
|
524
525
|
},
|
|
525
526
|
})
|
|
526
527
|
```
|
|
528
|
+
|
|
529
|
+
### Stricter Side-Effect Imports
|
|
530
|
+
|
|
531
|
+
🚦 **Impact Level**: Minimal
|
|
532
|
+
|
|
533
|
+
#### What Changed
|
|
534
|
+
|
|
535
|
+
With `compatibilityVersion: 5`, Nuxt's generated `tsconfig.json` enables [`noUncheckedSideEffectImports`](https://www.typescriptlang.org/tsconfig/#noUncheckedSideEffectImports). This is a default in TypeScript 7, so adopting it early keeps your project aligned ahead of that upgrade.
|
|
536
|
+
|
|
537
|
+
With this option on, a side-effect-only import (`import './setup'`) that TypeScript cannot resolve to a module is now a type error, whereas it was previously ignored. This only affects type-checking (`nuxt typecheck` and your editor), not runtime behavior.
|
|
538
|
+
|
|
539
|
+
#### Reasons for Change
|
|
540
|
+
|
|
541
|
+
Unresolved side-effect imports were silently ignored, so a typo or a deleted file could pass type-checking. Flagging them catches these mistakes and matches the TypeScript 7 default.
|
|
542
|
+
|
|
543
|
+
#### Migration Steps
|
|
544
|
+
|
|
545
|
+
If type-checking now errors on a side-effect import of a non-code asset (for example `import '~/assets/styles.css'`), add an ambient module declaration so TypeScript knows the import is valid:
|
|
546
|
+
|
|
547
|
+
```ts [types.d.ts]
|
|
548
|
+
declare module '*.css' {}
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
::tip
|
|
552
|
+
You can revert to the previous behavior by disabling the option in your `nuxt.config`:
|
|
553
|
+
|
|
554
|
+
<!-- @case-police-ignore tsConfig -->
|
|
555
|
+
|
|
556
|
+
```ts twoslash [nuxt.config.ts]
|
|
557
|
+
export default defineNuxtConfig({
|
|
558
|
+
typescript: {
|
|
559
|
+
tsConfig: {
|
|
560
|
+
compilerOptions: {
|
|
561
|
+
noUncheckedSideEffectImports: false,
|
|
562
|
+
},
|
|
563
|
+
},
|
|
564
|
+
},
|
|
565
|
+
})
|
|
566
|
+
```
|
|
567
|
+
::
|