Refine filesystem output types#94514
Draft
timneutkens wants to merge 1 commit into
Draft
Conversation
Contributor
Failing CI jobsCommit: b5c6320 | About building and testing Next.js |
Contributor
Stats cancelledCommit: b5c6320 |
8a7391d to
6797e1e
Compare
2d68f4c to
b5c6320
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Convert
FsOutputinto a string-discriminated union so each filesystem output exposes only the fields valid for its type.This PR is stacked on #94157.
Why?
The previous optional-field shape allowed invalid combinations and required downstream optional checks even when a route or filesystem path must exist. Narrower variants make those invariants explicit and expose invalid construction paths during type checking.
How?
typein route resolution and router dispatch before accessing specialized fields.Verification
pnpm --filter=next typespnpm --filter=next buildNEXT_TEST_PREFER_OFFLINE=1 pnpm test-dev-turbo test/e2e/dynamic-routing/dynamic-routing.test.ts test/e2e/middleware-general/test/index.test.ts -t "should resolve dynamic route href for page added later|should only contain middleware route in dev middleware manifest"NEXT_TEST_PREFER_OFFLINE=1 pnpm test-dev-webpack test/e2e/dynamic-routing/dynamic-routing.test.ts test/e2e/middleware-general/test/index.test.ts -t "should resolve dynamic route href for page added later|should only contain middleware route in dev middleware manifest"_next/static, image optimization, static metadata, development virtual manifests, and 404 handling under Turbopack and webpack.npx eslint --config eslint.config.mjs packages/next/src/server/lib/router-server.ts packages/next/src/server/lib/router-utils/filesystem.ts packages/next/src/server/lib/router-utils/resolve-routes.ts packages/next/src/server/lib/router-utils/setup-dev-bundler.tsgit diff --check