Skip to content

Commit

Permalink
feat(swr): add return type for swr client
Browse files Browse the repository at this point in the history
  • Loading branch information
CPatchane committed Mar 9, 2022
1 parent c234e7a commit 40345ed
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/core/generators/swr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
GetterPropType,
GetterResponse,
} from '../../types/getters';
import { camel } from '../../utils/case';
import { camel, pascal } from '../../utils/case';
import { toObjectString } from '../../utils/string';
import { isSyntheticDefaultImportsAllow } from '../../utils/tsconfig';
import { generateVerbImports } from './imports';
Expand Down Expand Up @@ -205,6 +205,11 @@ const generateSwrImplementation = ({
}

return `
export type ${pascal(
operationName,
)}QueryResult = NonNullable<AsyncReturnType<typeof ${operationName}>>
export type ${pascal(operationName)}QueryError = ${errorType}
export const ${camel(
`use-${operationName}`,
)} = <TError = ${errorType}>(\n ${swrProps} ${generateSwrArguments({
Expand Down

0 comments on commit 40345ed

Please sign in to comment.