You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This seems incorrect, since this type defines Component and router as required props. As a result, it is impossible to use AppTree in getInitialProps of a page component without manually overriding the type, since there is no way to access Component and router from NextPageContext. AppTree appears to work just fine without the props defined as required -- and in fact the official with-apollo example uses AppTree in precisely this way.
I'm overriding the types for AppTree in this HOC (very loosely based on the official with-apollo example) in order to make it work in TypeScript (see FixedAppTree).
If you replace FixedAppTree with the original AppTree on line 56 the TS compiler will complain about missing props:
Type '{ pageProps: { apolloClient: ApolloClient<NormalizedCacheObject>; }; }' is missing the following properties from type '{ Component: NextComponentType<NextPageContext, any, {}>; router: NextRouter; }': Component, routerts(2739)
Expected behavior
The default type of AppTree should not define Component and router as required props.
System information
OS: macOS
Browser: N/A
Version of Next.js: 9.0.5
Additional context
TypeScript version: 3.6.2
The text was updated successfully, but these errors were encountered:
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
vercel
locked as resolved and limited conversation to collaborators
Jan 31, 2022
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Bug report
Describe the bug
Currently the TS type for AppTree component is
AppType
:This seems incorrect, since this type defines
Component
androuter
as required props. As a result, it is impossible to use AppTree in getInitialProps of a page component without manually overriding the type, since there is no way to accessComponent
androuter
fromNextPageContext
.AppTree
appears to work just fine without the props defined as required -- and in fact the official with-apollo example uses AppTree in precisely this way.To Reproduce
lib/apollo.tsx
AppTree
in this HOC (very loosely based on the official with-apollo example) in order to make it work in TypeScript (seeFixedAppTree
).FixedAppTree
with the originalAppTree
on line 56 the TS compiler will complain about missing props:Expected behavior
The default type of
AppTree
should not defineComponent
androuter
as required props.System information
Additional context
The text was updated successfully, but these errors were encountered: