Skip to content

Commit

Permalink
Allow typing for useFaustQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
blakewilson committed Nov 3, 2023
1 parent d0ff52c commit 3bd56f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/faustwp-core/src/hooks/useFaustContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { sha256 } from 'js-sha256';
import { useContext } from 'react';
import { FaustContext } from '../store/FaustContext.js';

export function useFaustQuery(query: DocumentNode) {
export function useFaustQuery<TData>(query: DocumentNode): TData {
const context = useContext(FaustContext);

if (context === undefined) {
Expand All @@ -15,5 +15,5 @@ export function useFaustQuery(query: DocumentNode) {
const sha = sha256(print(query));

// eslint-disable-next-line no-underscore-dangle
return context?.__FAUST_QUERIES__?.[sha];
return context?.__FAUST_QUERIES__?.[sha] as TData;
}
2 changes: 1 addition & 1 deletion packages/faustwp-core/src/store/FaustContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FaustPageProps } from '../components/FaustProvider.js';
export const FaustContext = createContext<
| ({
__FAUST_QUERIES__?: {
[key: string]: string;
[key: string]: any;
};
} & FaustPageProps)
| undefined
Expand Down

0 comments on commit 3bd56f6

Please sign in to comment.