Types: have Gssp<T> accept query generic param
mdaverde opened this issue ยท comments
Milan commented
Some of the getServerSideProps
functions I want to use have overridden the 2nd generic param after Props:
interface Query extends ParsedUrlQuery {
slug: string;
}
export const getServerSideProps: GetServerSideProps<Props, Query> = async function (ctx) { ...};
But it doesn't seem like TS is happy when I use those generic overrides with this package:
export const getServerSideProps: GetServerSideProps<Props, Query> = composeServerSideProps({
use: [withServerAuth, withBlogPost],
});
// TS error:
Type error: No overload matches this call.
The last overload gave the following error.
Type 'GetServerSideProps<Props, Query, PreviewData>' is not assignable to type 'Gssp<unknown>'.
Types of parameters 'context' and 'context' are incompatible.
Type 'GetServerSidePropsContext<ParsedUrlQuery, PreviewData>' is not assignable to type 'GetServerSidePropsContext<Query, PreviewData>'.
Property 'slug' is missing in type 'Dict<string | string[]>' but required in type 'Query'.
Can we allow the second generic param through Gssp
? Other users might actually need this in Gip<T>
and Gsp<T>
as well?
Ryล Igarashi commented
Milan commented
This works for me! Just tried it locally. Thank you ๐
github-actions commented
๐ This issue has been resolved in version 1.1.0 ๐
The release is available on:
Your semantic-release bot ๐ฆ๐