Repository navigation
feat(nuxt,nitro): auto-import types from app/types and server/types directories - #35783
Conversation
app/types and server/types directories
@nuxt/kit
@nuxt/nitro-server
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🧹 Nitpick comments (2)
docs/2.directory-structure/1.server.md (1)
169-187: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winVerify the documented flat-directory guarantee with a regression test.
The documentation now promises that nested
server/typesfiles are excluded, but the implementation only registers the directory with Nitro and the current snapshot checks directory registration, not scan depth. Add a nested fixture and assert that its type is not auto-imported, or explicitly constrain the scanner to direct files.Based on the documented contract and the supplied directory-only test, this behaviour still needs verification.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@docs/2.directory-structure/1.server.md` around lines 169 - 187, Add a regression test for the server types auto-import behavior using the existing directory-registration test setup: create a nested server/types fixture and verify its type is not available for auto-import, while preserving direct-file support. If the scanner currently includes nested files, constrain it to scan only files directly under server/types so the implementation matches the documented flat-directory contract.packages/nuxt/test/shared-dir-config.test.ts (1)
11-41: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover the
nitroAutoImports: falseopt-out.These tests cover default directory discovery and app/server separation, but not the PR objective that
experimental.nitroAutoImports: falsedisables Nitro auto-imports. Add a case that capturesconfig.importsand asserts it isfalse(or at least that noserver/typesdirectory is passed).Based on the PR objective, this opt-out is an explicit acceptance criterion.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/nuxt/test/shared-dir-config.test.ts` around lines 11 - 41, Extend the shared-directory configuration tests with a case that configures experimental.nitroAutoImports as false, captures the resulting config.imports value, and asserts the opt-out is preserved as false (or prevents server/types from being passed). Reuse the existing test setup and configuration symbols rather than changing the default directory-discovery assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@docs/2.directory-structure/1.server.md`:
- Around line 169-187: Add a regression test for the server types auto-import
behavior using the existing directory-registration test setup: create a nested
server/types fixture and verify its type is not available for auto-import, while
preserving direct-file support. If the scanner currently includes nested files,
constrain it to scan only files directly under server/types so the
implementation matches the documented flat-directory contract.
In `@packages/nuxt/test/shared-dir-config.test.ts`:
- Around line 11-41: Extend the shared-directory configuration tests with a case
that configures experimental.nitroAutoImports as false, captures the resulting
config.imports value, and asserts the opt-out is preserved as false (or prevents
server/types from being passed). Reuse the existing test setup and configuration
symbols rather than changing the default directory-discovery assertions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 68832a56-303e-4187-a2c5-973781e994a2
📒 Files selected for processing (6)
docs/2.directory-structure/1.app/1.utils.mddocs/2.directory-structure/1.server.mddocs/2.directory-structure/1.shared.mdpackages/nitro-server/src/index.tspackages/nuxt/src/imports/module.tspackages/nuxt/test/shared-dir-config.test.ts
Merging this PR will degrade performance by 11.27%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | writeTypes in the basic-types fixture |
46.2 ms | 52.3 ms | -11.61% |
| ❌ | loadNuxt in the basic test fixture |
382.6 ms | 429.6 ms | -10.92% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing Flo0806:feat/app-server-types (29047bb) with main (ba42831)
Footnotes
-
3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
🔗 Linked issue
Resolves: #35763
📚 Description
Now types (flat) in
app/typesare auto-imported by Nuxt. Alsoserver/types. This let you make a more clear structure if needed.The flag
experimental.nitroAutoImports === falsedisables the nitroserver/typesauto-import, too.Tests
Added tests
Docs
Docs are updated on three places