Skip to content

Commit

Permalink
chore: turn on noUncheckedIndexedAccess compiler flag (TanStack#2341)
Browse files Browse the repository at this point in the history
  • Loading branch information
TkDodo authored Jun 5, 2021
1 parent 0de83ae commit 2b8d2af
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/core/tests/queryClient.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ describe('queryClient', () => {
const data = {
pages: ['data'],
pageParams: [undefined],
}
} as const

const fetchFn: QueryFunction<StrictData, StrictQueryKey> = () =>
Promise.resolve(data.pages[0])
Expand Down
8 changes: 4 additions & 4 deletions src/core/tests/utils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,10 @@ describe('core/utils', () => {
expect(result.todos).not.toBe(next.todos)
expect(result.todos[0]).not.toBe(prev.todos[0])
expect(result.todos[0]).not.toBe(next.todos[0])
expect(result.todos[0].id).toBe(next.todos[0].id)
expect(result.todos[0].meta).toBe(prev.todos[0].meta)
expect(result.todos[0].state).not.toBe(next.todos[0].state)
expect(result.todos[0].state.done).toBe(next.todos[0].state.done)
expect(result.todos[0]?.id).toBe(next.todos[0]?.id)
expect(result.todos[0]?.meta).toBe(prev.todos[0]?.meta)
expect(result.todos[0]?.state).not.toBe(next.todos[0]?.state)
expect(result.todos[0]?.state.done).toBe(next.todos[0]?.state.done)
expect(result.todos[1]).toBe(prev.todos[1])
})
})
Expand Down
18 changes: 9 additions & 9 deletions src/react/tests/useQuery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ describe('useQuery', () => {
expect(states[0]).toMatchObject({ data: undefined, isFetching: true })
expect(states[1]).toMatchObject({ data: 'test', isFetching: false })
expect(states[2]).toMatchObject({ data: 'test', isFetching: false })
expect(states[1].dataUpdatedAt).not.toBe(states[2].dataUpdatedAt)
expect(states[1]?.dataUpdatedAt).not.toBe(states[2]?.dataUpdatedAt)
})

it('should track properties and only re-render when a tracked property changes', async () => {
Expand Down Expand Up @@ -1039,13 +1039,13 @@ describe('useQuery', () => {

await waitFor(() => expect(states.length).toBe(4))

const todos = states[2].data!
const todo1 = todos[0]
const todo2 = todos[1]
const todos = states[2]?.data
const todo1 = todos?.[0]
const todo2 = todos?.[1]

const newTodos = states[3].data!
const newTodo1 = newTodos[0]
const newTodo2 = newTodos[1]
const newTodos = states[3]?.data
const newTodo1 = newTodos?.[0]
const newTodo2 = newTodos?.[1]

expect(todos).toEqual(result1)
expect(newTodos).toEqual(result2)
Expand Down Expand Up @@ -1465,7 +1465,7 @@ describe('useQuery', () => {
status: 'error',
isPreviousData: false,
})
expect(states[7].error).toHaveProperty('message', 'Error test')
expect(states[7]?.error).toHaveProperty('message', 'Error test')

consoleMock.mockRestore()
})
Expand Down Expand Up @@ -2304,7 +2304,7 @@ describe('useQuery', () => {

await sleep(20)

expect(states[1].data).toEqual([key, variables])
expect(states[1]?.data).toEqual([key, variables])
})

it('should not refetch query on focus when `enabled` is set to `false`', async () => {
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noUncheckedIndexedAccess": true,
"skipLibCheck": true,
"strict": true,
"types": ["jest"],
Expand Down

0 comments on commit 2b8d2af

Please sign in to comment.