Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disallow implicit returns #4640

Merged
merged 1 commit into from Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/query-async-storage-persister/src/index.ts
Expand Up @@ -55,6 +55,7 @@ export const createAsyncStoragePersister = ({
): Promise<Error | undefined> => {
try {
await storage.setItem(key, serialize(persistedClient))
return
} catch (error) {
return error as Error
}
Expand Down
1 change: 1 addition & 0 deletions packages/query-core/src/focusManager.ts
Expand Up @@ -28,6 +28,7 @@ export class FocusManager extends Subscribable {
window.removeEventListener('focus', listener)
}
}
return
}
}

Expand Down
2 changes: 2 additions & 0 deletions packages/query-core/src/infiniteQueryBehavior.ts
Expand Up @@ -193,6 +193,7 @@ export function hasNextPage(
nextPageParam !== false
)
}
return
}

/**
Expand All @@ -211,4 +212,5 @@ export function hasPreviousPage(
previousPageParam !== false
)
}
return
}
2 changes: 2 additions & 0 deletions packages/query-core/src/onlineManager.ts
Expand Up @@ -28,6 +28,8 @@ export class OnlineManager extends Subscribable {
window.removeEventListener('offline', listener)
}
}

return
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/query-core/src/retryer.ts
Expand Up @@ -185,6 +185,7 @@ export function createRetryer<TData = unknown, TError = unknown>(
if (shouldPause()) {
return pause()
}
return
})
.then(() => {
if (isRetryCancelled) {
Expand Down
1 change: 1 addition & 0 deletions packages/query-core/src/utils.ts
Expand Up @@ -418,6 +418,7 @@ export function getAbortController(): AbortController | undefined {
if (typeof AbortController === 'function') {
return new AbortController()
}
return
}

export function replaceData<
Expand Down
1 change: 1 addition & 0 deletions packages/query-sync-storage-persister/src/index.ts
Expand Up @@ -46,6 +46,7 @@ export function createSyncStoragePersister({
const trySave = (persistedClient: PersistedClient): Error | undefined => {
try {
storage.setItem(key, serialize(persistedClient))
return
} catch (error) {
return error as Error
}
Expand Down
2 changes: 2 additions & 0 deletions packages/react-query-devtools/src/devtools.tsx
Expand Up @@ -244,6 +244,7 @@ export function ReactQueryDevtools({
ref.removeEventListener('transitionend', handlePanelTransitionEnd)
}
}
return
}, [isResolvedOpen])

React.useEffect(() => {
Expand Down Expand Up @@ -296,6 +297,7 @@ export function ReactQueryDevtools({
}
}
}
return
}, [isResolvedOpen, panelPosition, devtoolsHeight, devtoolsWidth])

const { style: panelStyle = {}, ...otherPanelProps } = panelProps
Expand Down
2 changes: 2 additions & 0 deletions packages/react-query-devtools/src/useMediaQuery.ts
Expand Up @@ -6,6 +6,7 @@ export default function useMediaQuery(query: string): boolean | undefined {
if (typeof window !== 'undefined') {
return window.matchMedia(query).matches
}
return
})

// Watch for changes
Expand All @@ -26,6 +27,7 @@ export default function useMediaQuery(query: string): boolean | undefined {
matcher.removeListener(onChange)
}
}
return
}, [isMatch, query, setIsMatch])

return isMatch
Expand Down
Expand Up @@ -32,6 +32,7 @@ describe('Discriminated union return type', () => {
true
return result
}
return
})
})

Expand All @@ -47,6 +48,7 @@ describe('Discriminated union return type', () => {
const result: Expect<Equal<null, typeof query.error>> = true
return result
}
return
})
})

Expand All @@ -62,6 +64,7 @@ describe('Discriminated union return type', () => {
const result: Expect<Equal<undefined, typeof query.data>> = true
return result
}
return
})
})

Expand All @@ -77,6 +80,7 @@ describe('Discriminated union return type', () => {
const result: Expect<Equal<unknown, typeof query.error>> = true
return result
}
return
})
})
})
4 changes: 4 additions & 0 deletions packages/vue-query/src/__tests__/useMutation.types.test.tsx
Expand Up @@ -25,6 +25,7 @@ describe('Discriminated union return type', () => {
const result: Expect<Equal<string, typeof mutation.data>> = true
return result
}
return
})
})

Expand All @@ -38,6 +39,7 @@ describe('Discriminated union return type', () => {
const result: Expect<Equal<null, typeof mutation.error>> = true
return result
}
return
})
})

Expand All @@ -51,6 +53,7 @@ describe('Discriminated union return type', () => {
const result: Expect<Equal<undefined, typeof mutation.data>> = true
return result
}
return
})
})

Expand All @@ -64,6 +67,7 @@ describe('Discriminated union return type', () => {
const result: Expect<Equal<unknown, typeof mutation.error>> = true
return result
}
return
})
})
})
4 changes: 4 additions & 0 deletions packages/vue-query/src/__tests__/useQuery.types.test.tsx
Expand Up @@ -28,6 +28,7 @@ describe('Discriminated union return type', () => {
const result: Expect<Equal<string, typeof query.data>> = true
return result
}
return
})
})

Expand All @@ -43,6 +44,7 @@ describe('Discriminated union return type', () => {
const result: Expect<Equal<null, typeof query.error>> = true
return result
}
return
})
})

Expand All @@ -58,6 +60,7 @@ describe('Discriminated union return type', () => {
const result: Expect<Equal<undefined, typeof query.data>> = true
return result
}
return
})
})

Expand All @@ -73,6 +76,7 @@ describe('Discriminated union return type', () => {
const result: Expect<Equal<unknown, typeof query.error>> = true
return result
}
return
})
})
})
2 changes: 1 addition & 1 deletion tsconfig.base.json
Expand Up @@ -7,7 +7,7 @@
"allowSyntheticDefaultImports": true,
"strict": true,
"noImplicitAny": true,
"noImplicitReturns": false,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
Expand Down