next.js
a3f031d8 - fix: rootParams should throw in client when fallbackParams are not present (#81711)

Commit
164 days ago
fix: rootParams should throw in client when fallbackParams are not present (#81711) `rootParams` was erroring if used in a `'prerender-client'`, but only if we had `fallbackRouteParams`. this is an edge case, but it is technically possible to hit if our compiler checks for using `rootParams` in client code are bypassed. i've also had to split `PrerenderStoreModern` into two types instead of having `type: 'prerender' | 'prerender-client'`. otherwise, typescript would think that the `case 'prerender'` branch wasn't enough to eliminate `PrerenderStoreModern` even though we already handled the `prerender-client` case at the top. this made the `prerenderStore satisfies never` assertion at the bottom fail. This is a bit tricky to explain, so i'm including a [TS playground repro](https://www.typescriptlang.org/play/?#code/C4TwDgpgBAysD2AnCAZCBzAhgYxFAvFAN5SiQBcUA5GMsgHYAmEiAtADYY4hUC+AUGWhwkEALLxmiegWKlwESjToQmLKlAA+1Wi1VTW2dgEtVwDQKGwEyWSORosuLddESp9fvwgAPMEmAoADMAV3psYGN4GQBnFgA3FgB5enYQABUAC2N6dAAKGJtFV2QASkpCxBz0Yn4oeqhjIKgCooA6K3wunRU1NiNTenNS2oax0kzEeAB3KHoIWYBRRCnEPKoAOXhAzHZ2GYhGRpkBsypSuoaBMZjp42BsTJbC0Q6FEaJL8agAeh+obCYOI9PR9QwmM5fcZ-KAAPSgAGFMPQqIFGPAJsYYlBMnooJgsDkADRQdIwKAsVbYu7AJ4AA3SCmoACJdAwDKchsyNFi5tsAfAALZgTCITAAI04pAxViorN6Bk4ThAzJc8tBUm5bTpULGMLy4oggJCwOm0EeRoA1ocJphAoagqIAIQXXUNQHA5Qa9SUT7fb7IYAhaRQZkAdQgVFsOXxUEFkhYMjZ+hYzLd9Wu-o90C97JYHC4uCovvT40DwZk4cj0ZkmCgSu4UGTfTT-qgme+zCCmBC7GAJbbNyKUBidqxQVM2PmiUQpb1-1hAH45w0YW11+KQoEyZj6JbsXSXsg6QDkSPInsoIbY-ZxAmQ7jbBBEjJafAQugnmaqIkKSZBTkdo2uK2xPP4MQxMYkrmkCEDYqWHbtvwAhAA) i'm guessing that `type: 'prerender' | 'prerender-client'` is more complex than a normal discriminator and TS was getting confused, which is why having two separate types solves it.
Author
Parents
Loading