next.js
e1034776 - Fix for `typedRoutes` when setting `pageExtensions` - for typedRoutes MDX support (#67824)

Commit
1 year ago
Fix for `typedRoutes` when setting `pageExtensions` - for typedRoutes MDX support (#67824) ### What? **Fixes MDX support for `typedRoutes`** Updates the `next-types` webpack plugin to consider the full array of user-defined `pageExtensions` when deciding whether to include a file as a route (rather than using the hardcoded pattern `js|jsx|ts|tsx|mjs`). ### Why? Without this PR, `typedRoutes` produces false-positive type errors when linking to MDX pages, because MDX pages aren’t included in the generated types - see #67822. But it’s not specific to MDX—this bug affects any file type that’s added via [`pageExtensions`](https://nextjs.org/docs/app/api-reference/next-config-js/pageExtensions) outside of `js`, `jsx`, `ts`, `tsx`, or `mjs`. ### How? Constructs a page-extension regex from `options.pageExtensions`, instead of hardcoding the regex `/\.(js|jsx|ts|tsx|mjs)$/` ### Fixes Fixes #67822 Fixes #62335 Supersedes #62402 Tests updated to cover this case cc @shuding --------- Co-authored-by: JJ Kasper <jj@jjsweb.site>
Author
Parents
Loading