Skip to content

Commit

Permalink
chore(imports): update the imports declarations of type annotations a…
Browse files Browse the repository at this point in the history
…nd declarations to `import type` (#606)
  • Loading branch information
liby committed Jul 20, 2021
1 parent 2c3e3c3 commit afa0a34
Show file tree
Hide file tree
Showing 31 changed files with 61 additions and 44 deletions.
3 changes: 2 additions & 1 deletion examples/mega-form/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useCallback, useMemo } from 'react'
import { PrimitiveAtom, Provider, atom, useAtom } from 'jotai'
import { Provider, atom, useAtom } from 'jotai'
import type { PrimitiveAtom } from 'jotai'
import { focusAtom } from 'jotai/optics'
import { useAtomCallback } from 'jotai/utils'
import initialValue from './initialValue'
Expand Down
3 changes: 2 additions & 1 deletion examples/mega-form/src/useAtomSlice.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useMemo } from 'react'
import { PrimitiveAtom, useAtom } from 'jotai'
import { useAtom } from 'jotai'
import type { PrimitiveAtom } from 'jotai'
import { splitAtom } from 'jotai/utils'

const useAtomSlice = <Item>(arrAtom: PrimitiveAtom<Item[]>) => {
Expand Down
5 changes: 3 additions & 2 deletions examples/todos/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { FormEvent } from 'react'
import type { FormEvent } from 'react'
import { CloseOutlined } from '@ant-design/icons'
import { a, useTransition } from '@react-spring/web'
import { Radio } from 'antd'
import { PrimitiveAtom, Provider, atom, useAtom } from 'jotai'
import { Provider, atom, useAtom } from 'jotai'
import type { PrimitiveAtom } from 'jotai'
import { useUpdateAtom } from 'jotai/utils'

type Todo = {
Expand Down
2 changes: 1 addition & 1 deletion examples/todos_with_atomFamily/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormEvent } from 'react'
import type { FormEvent } from 'react'
import { CloseOutlined } from '@ant-design/icons'
import { a, useTransition } from '@react-spring/web'
import { Radio } from 'antd'
Expand Down
3 changes: 2 additions & 1 deletion src/core/Provider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PropsWithChildren, createElement, useDebugValue, useRef } from 'react'
import { createElement, useDebugValue, useRef } from 'react'
import type { PropsWithChildren } from 'react'
import type { Atom, Scope } from './atom'
import { createStore, getStoreContext, isDevStore } from './contexts'
import type { StoreForDevelopment } from './contexts'
Expand Down
3 changes: 2 additions & 1 deletion src/devtools/useAtomDevtools.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEffect, useRef } from 'react'
import { WritableAtom, useAtom } from 'jotai'
import { useAtom } from 'jotai'
import type { WritableAtom } from 'jotai'

type Config = {
instanceID?: number
Expand Down
6 changes: 4 additions & 2 deletions src/immer/atomWithImmer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint-disable import/named */
import { Draft, produce } from 'immer'
import { WritableAtom, atom } from 'jotai'
import { produce } from 'immer'
import type { Draft } from 'immer'
import { atom } from 'jotai'
import type { WritableAtom } from 'jotai'

export function atomWithImmer<Value>(
initialValue: Value
Expand Down
6 changes: 4 additions & 2 deletions src/immer/useImmerAtom.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* eslint-disable import/named */
import { useCallback } from 'react'
import { Draft, produce } from 'immer'
import { WritableAtom, useAtom } from 'jotai'
import { produce } from 'immer'
import type { Draft } from 'immer'
import { useAtom } from 'jotai'
import type { WritableAtom } from 'jotai'

export function useImmerAtom<Value>(
anAtom: WritableAtom<Value, (draft: Draft<Value>) => void>
Expand Down
6 changes: 4 additions & 2 deletions src/immer/withImmer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint-disable import/named */
import { Draft, produce } from 'immer'
import { PrimitiveAtom, WritableAtom, atom } from 'jotai'
import { produce } from 'immer'
import type { Draft } from 'immer'
import { atom } from 'jotai'
import type { PrimitiveAtom, WritableAtom } from 'jotai'
import { getWeakCacheItem, setWeakCacheItem } from '../utils/weakCache'

const withImmerCache = new WeakMap()
Expand Down
7 changes: 2 additions & 5 deletions src/optics/focusAtom.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import * as O from 'optics-ts'
import { atom } from 'jotai'
import type { SetStateAction, WritableAtom } from 'jotai'
import {
WeakCache,
getWeakCacheItem,
setWeakCacheItem,
} from '../utils/weakCache'
import { getWeakCacheItem, setWeakCacheItem } from '../utils/weakCache'
import type { WeakCache } from '../utils/weakCache'

const focusAtomCache: WeakCache<WritableAtom<any, any>> = new WeakMap()

Expand Down
5 changes: 2 additions & 3 deletions src/query/atomWithInfiniteQuery.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import {
import { InfiniteQueryObserver, isCancelledError } from 'react-query'
import type {
InfiniteData,
InfiniteQueryObserver,
InfiniteQueryObserverOptions,
InitialDataFunction,
QueryClient,
QueryKey,
QueryObserverResult,
isCancelledError,
} from 'react-query'
import { atom } from 'jotai'
import type { Getter, WritableAtom } from 'jotai'
Expand Down
4 changes: 2 additions & 2 deletions src/query/atomWithQuery.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
import { QueryObserver } from 'react-query'
import type {
InitialDataFunction,
QueryClient,
QueryKey,
QueryObserver,
QueryObserverOptions,
QueryObserverResult,
} from 'react-query'
Expand Down
2 changes: 1 addition & 1 deletion src/urql/atomWithMutation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Client,
OperationContext,
OperationResult,
Expand Down
2 changes: 1 addition & 1 deletion src/urql/atomWithQuery.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Client,
OperationContext,
OperationResult,
Expand Down
2 changes: 1 addition & 1 deletion src/urql/atomWithSubscription.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Client,
OperationContext,
OperationResult,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/atomFamily.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Atom, WritableAtom } from 'jotai'
import type { Atom, WritableAtom } from 'jotai'

type ShouldRemove<Param> = (createdAt: number, param: Param) => boolean

Expand Down
3 changes: 2 additions & 1 deletion src/utils/atomWithReducer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { WritableAtom, atom } from 'jotai'
import { atom } from 'jotai'
import type { WritableAtom } from 'jotai'

export function atomWithReducer<Value, Action>(
initialValue: Value,
Expand Down
3 changes: 2 additions & 1 deletion src/utils/selectAtom.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Atom, atom } from 'jotai'
import { atom } from 'jotai'
import type { Atom } from 'jotai'
import { getWeakCacheItem, setWeakCacheItem } from './weakCache'

const selectAtomCache = new WeakMap()
Expand Down
3 changes: 2 additions & 1 deletion src/utils/useAtomValue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Atom, useAtom } from 'jotai'
import { useAtom } from 'jotai'
import type { Atom } from 'jotai'

export function useAtomValue<Value>(anAtom: Atom<Value>) {
return useAtom(anAtom)[0]
Expand Down
3 changes: 2 additions & 1 deletion src/utils/useReducerAtom.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useCallback } from 'react'
import { PrimitiveAtom, useAtom } from 'jotai'
import { useAtom } from 'jotai'
import type { PrimitiveAtom } from 'jotai'

/* this doesn't seem to work as expected in TS4.1
export function useReducerAtom<Value, Action>(
Expand Down
4 changes: 2 additions & 2 deletions src/xstate/atomWithMachine.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
import { interpret } from 'xstate'
import type {
EventObject,
Interpreter,
InterpreterOptions,
MachineOptions,
State,
StateMachine,
Typestate,
interpret,
} from 'xstate'
import { atom } from 'jotai'
import type { Atom, Getter } from 'jotai'
Expand Down
3 changes: 2 additions & 1 deletion tests/async.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { StrictMode, Suspense, useEffect, useRef } from 'react'
import { fireEvent, render, waitFor } from '@testing-library/react'
import { Atom, atom, useAtom } from '../src/index'
import { atom, useAtom } from 'jotai'
import type { Atom } from 'jotai'
import { getTestProvider } from './testUtils'

const Provider = getTestProvider()
Expand Down
3 changes: 2 additions & 1 deletion tests/basic.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
useState,
} from 'react'
import { fireEvent, render, waitFor } from '@testing-library/react'
import { WritableAtom, atom, useAtom } from '../src/index'
import type { WritableAtom } from 'jotai'
import { atom, useAtom } from '../src/index'
import { getTestProvider } from './testUtils'

const Provider = getTestProvider()
Expand Down
3 changes: 2 additions & 1 deletion tests/items.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { fireEvent, render, waitFor } from '@testing-library/react'
import { PrimitiveAtom, atom, useAtom } from '../src/index'
import type { PrimitiveAtom } from 'jotai'
import { atom, useAtom } from '../src/index'
import { getTestProvider } from './testUtils'

const Provider = getTestProvider()
Expand Down
5 changes: 3 additions & 2 deletions tests/types.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expectType } from 'ts-expect'
import { SetAtom } from '../src/core/atom'
import { Atom, PrimitiveAtom, WritableAtom, atom, useAtom } from '../src/index'
import { atom, useAtom } from 'jotai'
import type { Atom, PrimitiveAtom, WritableAtom } from 'jotai'
import type { SetAtom } from '../src/core/atom'

it('atom() should return the correct types', () => {
function Component() {
Expand Down
2 changes: 1 addition & 1 deletion tests/urql/atomWithMutation.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Suspense } from 'react'
import { fireEvent, render } from '@testing-library/react'
import { Client } from '@urql/core'
import type { Client } from '@urql/core'
import { delay, fromValue, pipe, take, toPromise } from 'wonka'
import { atom, useAtom } from '../../src/'
import { atomWithMutation } from '../../src/urql'
Expand Down
2 changes: 1 addition & 1 deletion tests/urql/atomWithQuery.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Suspense } from 'react'
import { fireEvent, render } from '@testing-library/react'
import { Client } from '@urql/core'
import type { Client } from '@urql/core'
import { interval, map, pipe, take, toPromise } from 'wonka'
import { atom, useAtom } from '../../src/'
import { atomWithQuery } from '../../src/urql'
Expand Down
2 changes: 1 addition & 1 deletion tests/urql/atomWithSubscription.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Suspense } from 'react'
import { render } from '@testing-library/react'
import { Client, TypedDocumentNode } from '@urql/core'
import type { Client, TypedDocumentNode } from '@urql/core'
import { interval, map, pipe, take, toPromise } from 'wonka'
import { useAtom } from '../../src/'
import { atomWithSubscription } from '../../src/urql'
Expand Down
3 changes: 2 additions & 1 deletion tests/utils/splitAtom.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChangeEvent, useEffect, useRef } from 'react'
import { useEffect, useRef } from 'react'
import type { ChangeEvent } from 'react'
import { fireEvent, render, waitFor } from '@testing-library/react'
import { atom, useAtom } from 'jotai'
import type { Atom, PrimitiveAtom } from 'jotai'
Expand Down
3 changes: 2 additions & 1 deletion tests/utils/useUpdateAtom.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PropsWithChildren, StrictMode, useEffect, useRef } from 'react'
import { StrictMode, useEffect, useRef } from 'react'
import type { PropsWithChildren } from 'react'
import { fireEvent, render, waitFor } from '@testing-library/react'
import { atom, useAtom } from '../../src/index'
import { useUpdateAtom } from '../../src/utils'
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"target": "es2019",
"strict": true,
"jsx": "preserve",
"jsx": "react-jsx",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"moduleResolution": "node",
Expand Down

1 comment on commit afa0a34

@vercel
Copy link

@vercel vercel bot commented on afa0a34 Jul 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.