Skip to content

Commit 0ea83f6

Browse files
authored
Merge pull request #205 from yoshi6jp/main
fix type error. #204
2 parents dcf1cc7 + 893742e commit 0ea83f6

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/visitor.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,10 @@ export class SWRVisitor extends ClientSideBaseVisitor<
219219
if (this._enabledInfinite) {
220220
codes.push(` const utilsForInfinite = {
221221
generateGetKey: <Data = unknown, Variables = unknown>(
222-
id: string,
223-
getKey: ${config.typesPrefix}SWRInfiniteKeyLoader${config.typesSuffix}<Data, Variables>
222+
id: ${config.autogenSWRKey ? 'SWRKeyInterface' : 'string'},
223+
getKey: ${config.typesPrefix}SWRInfiniteKeyLoader${
224+
config.typesSuffix
225+
}<Data, Variables>
224226
) => (pageIndex: number, previousData: Data | null) => {
225227
const key = getKey(pageIndex, previousData)
226228
return key ? [id, ...key] : null

tests/outputs/autogenSWRKey.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export function getSdkWithHooks(client: GraphQLClient, withWrapper: SdkFunctionW
22
const sdk = getSdk(client, withWrapper);
33
const utilsForInfinite = {
44
generateGetKey: <Data = unknown, Variables = unknown>(
5-
id: string,
5+
id: SWRKeyInterface,
66
getKey: SWRInfiniteKeyLoader<Data, Variables>
77
) => (pageIndex: number, previousData: Data | null) => {
88
const key = getKey(pageIndex, previousData)

0 commit comments

Comments
 (0)