From 258282b8e81304331a094a9e8ac71533a7cfd279 Mon Sep 17 00:00:00 2001 From: lxr <1076629390@qq.com> Date: Tue, 22 Mar 2022 09:37:42 +0800 Subject: [PATCH] chore: optimize tsconfig (#1513) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: optimize tsconfig * fix: tslint 校验不通过 * fix: tslint 校验不通过 * chore: ts fix * chore: add production ts config Co-authored-by: 尽龙 --- docs/guide/dom.en-US.md | 6 ++--- docs/guide/dom.zh-CN.md | 6 ++--- gulpfile.js | 6 ++--- packages/hooks/src/global.d.ts | 5 ++++ .../hooks/src/useAsyncEffect/demo/demo1.tsx | 2 +- .../hooks/src/useAsyncEffect/demo/demo2.tsx | 4 ++-- .../hooks/src/useClickAway/demo/demo1.tsx | 2 +- .../hooks/src/useClickAway/demo/demo3.tsx | 4 ++-- .../hooks/src/useClickAway/demo/demo4.tsx | 2 +- .../hooks/src/useClickAway/demo/demo5.tsx | 2 +- packages/hooks/src/useDrop/demo/demo1.tsx | 4 ++-- .../hooks/src/useEventListener/demo/demo1.tsx | 2 +- packages/hooks/src/useExternal/demo/demo1.tsx | 2 +- .../hooks/src/useFocusWithin/demo/demo1.tsx | 2 +- .../hooks/src/useFullscreen/demo/demo1.tsx | 2 +- .../hooks/src/useHistoryTravel/demo/demo2.tsx | 13 +++++++--- packages/hooks/src/useHover/demo/demo1.tsx | 2 +- .../hooks/src/useInViewport/demo/demo1.tsx | 2 +- .../src/useInfiniteScroll/demo/mutate.tsx | 8 ++++--- .../src/useInfiniteScroll/demo/scroll.tsx | 2 +- packages/hooks/src/useInterval/demo/demo2.tsx | 2 +- packages/hooks/src/useKeyPress/demo/demo5.tsx | 2 +- .../hooks/src/useLongPress/demo/demo1.tsx | 2 +- .../hooks/src/useLongPress/demo/demo2.tsx | 2 +- packages/hooks/src/useMouse/demo/demo2.tsx | 2 +- .../hooks/src/usePagination/demo/demo4.tsx | 2 +- packages/hooks/src/useReactive/demo/demo2.tsx | 2 +- .../doc/basic/demo/formatResult.tsx | 24 ------------------- .../src/useRequest/doc/basic/demo/params.tsx | 4 ++-- packages/hooks/src/useSize/demo/demo1.tsx | 2 +- .../hooks/src/useTextSelection/demo/demo3.tsx | 2 +- .../hooks/src/useVirtualList/demo/demo1.tsx | 4 ++-- .../hooks/src/useVirtualList/demo/demo2.tsx | 4 ++-- packages/hooks/tsconfig.pro.json | 6 +++++ packages/use-url-state/tsconfig.pro.json | 6 +++++ tsconfig.json | 8 ++++--- tsconfig.pro.json | 14 +++++++++++ 37 files changed, 92 insertions(+), 74 deletions(-) create mode 100644 packages/hooks/src/global.d.ts delete mode 100644 packages/hooks/src/useRequest/doc/basic/demo/formatResult.tsx create mode 100644 packages/hooks/tsconfig.pro.json create mode 100644 packages/use-url-state/tsconfig.pro.json create mode 100644 tsconfig.pro.json diff --git a/docs/guide/dom.en-US.md b/docs/guide/dom.en-US.md index d939f0c4d7..8a578ad4c5 100644 --- a/docs/guide/dom.en-US.md +++ b/docs/guide/dom.en-US.md @@ -8,7 +8,7 @@ Most of the DOM Hooks will receive the `target` parameter, which indicates the e ```ts export default () => { - const ref = useRef(); + const ref = useRef(null); const isHovering = useHover(ref); return
{isHovering ? 'hover' : 'leaveHover'}
; }; @@ -38,8 +38,8 @@ In addition, **the `target` of DOM Hooks supports dynamic changes**. for example export default () => { const [boolean, { toggle }] = useBoolean(); - const ref = useRef(); - const ref2 = useRef(); + const ref = useRef(null); + const ref2 = useRef(null); const isHovering = useHover(boolean ? ref : ref2); return ( diff --git a/docs/guide/dom.zh-CN.md b/docs/guide/dom.zh-CN.md index 16101d56ae..078ba2e25e 100644 --- a/docs/guide/dom.zh-CN.md +++ b/docs/guide/dom.zh-CN.md @@ -8,7 +8,7 @@ ahooks 大部分 DOM 类 Hooks 都会接收 `target` 参数,表示要处理的 ```ts export default () => { - const ref = useRef(); + const ref = useRef(null); const isHovering = useHover(ref); return
{isHovering ? 'hover' : 'leaveHover'}
; }; @@ -38,8 +38,8 @@ export default () => { export default () => { const [boolean, { toggle }] = useBoolean(); - const ref = useRef(); - const ref2 = useRef(); + const ref = useRef(null); + const ref2 = useRef(null); const isHovering = useHover(boolean ? ref : ref2); return ( diff --git a/gulpfile.js b/gulpfile.js index 00c4a319b2..e7e4507ba2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -10,7 +10,7 @@ gulp.task('clean', async function () { }); gulp.task('cjs', function () { - const tsProject = ts.createProject('tsconfig.json', { + const tsProject = ts.createProject('tsconfig.pro.json', { module: 'CommonJS', }); return tsProject @@ -25,7 +25,7 @@ gulp.task('cjs', function () { }); gulp.task('es', function () { - const tsProject = ts.createProject('tsconfig.json', { + const tsProject = ts.createProject('tsconfig.pro.json', { module: 'ESNext', }); return tsProject @@ -40,7 +40,7 @@ gulp.task('es', function () { }); gulp.task('declaration', function () { - const tsProject = ts.createProject('tsconfig.json', { + const tsProject = ts.createProject('tsconfig.pro.json', { declaration: true, emitDeclarationOnly: true, }); diff --git a/packages/hooks/src/global.d.ts b/packages/hooks/src/global.d.ts new file mode 100644 index 0000000000..52c0a4f605 --- /dev/null +++ b/packages/hooks/src/global.d.ts @@ -0,0 +1,5 @@ +declare module '*.jpg'; + +interface Window { + TEST_SCRIPT?: any; +} diff --git a/packages/hooks/src/useAsyncEffect/demo/demo1.tsx b/packages/hooks/src/useAsyncEffect/demo/demo1.tsx index 73f9487fda..89d2ae1359 100644 --- a/packages/hooks/src/useAsyncEffect/demo/demo1.tsx +++ b/packages/hooks/src/useAsyncEffect/demo/demo1.tsx @@ -18,7 +18,7 @@ function mockCheck(): Promise { } export default () => { - const [pass, setPass] = useState(null); + const [pass, setPass] = useState(); useAsyncEffect(async () => { setPass(await mockCheck()); diff --git a/packages/hooks/src/useAsyncEffect/demo/demo2.tsx b/packages/hooks/src/useAsyncEffect/demo/demo2.tsx index 209c8a0ef2..a84b931ac6 100644 --- a/packages/hooks/src/useAsyncEffect/demo/demo2.tsx +++ b/packages/hooks/src/useAsyncEffect/demo/demo2.tsx @@ -19,11 +19,11 @@ function mockCheck(val: string): Promise { export default () => { const [value, setValue] = useState(''); - const [pass, setPass] = useState(null); + const [pass, setPass] = useState(); useAsyncEffect( async function* () { - setPass(null); + setPass(undefined); const result = await mockCheck(value); yield; // Check whether the effect is still valid, if it is has been cleaned up, stop at here. setPass(result); diff --git a/packages/hooks/src/useClickAway/demo/demo1.tsx b/packages/hooks/src/useClickAway/demo/demo1.tsx index 1b64a5aac2..6232f37399 100644 --- a/packages/hooks/src/useClickAway/demo/demo1.tsx +++ b/packages/hooks/src/useClickAway/demo/demo1.tsx @@ -11,7 +11,7 @@ import { useClickAway } from 'ahooks'; export default () => { const [counter, setCounter] = useState(0); - const ref = useRef(); + const ref = useRef(null); useClickAway(() => { setCounter((s) => s + 1); }, ref); diff --git a/packages/hooks/src/useClickAway/demo/demo3.tsx b/packages/hooks/src/useClickAway/demo/demo3.tsx index 0d6fdaa9ab..c7c0cdd5bd 100644 --- a/packages/hooks/src/useClickAway/demo/demo3.tsx +++ b/packages/hooks/src/useClickAway/demo/demo3.tsx @@ -11,8 +11,8 @@ import { useClickAway } from 'ahooks'; export default () => { const [counter, setCounter] = useState(0); - const ref1 = useRef(); - const ref2 = useRef(); + const ref1 = useRef(null); + const ref2 = useRef(null); useClickAway(() => { setCounter((s) => s + 1); }, [ref1, ref2]); diff --git a/packages/hooks/src/useClickAway/demo/demo4.tsx b/packages/hooks/src/useClickAway/demo/demo4.tsx index d37aea4417..b1fb69f832 100644 --- a/packages/hooks/src/useClickAway/demo/demo4.tsx +++ b/packages/hooks/src/useClickAway/demo/demo4.tsx @@ -11,7 +11,7 @@ import { useClickAway } from 'ahooks'; export default () => { const [counter, setCounter] = useState(0); - const ref = useRef(); + const ref = useRef(null); useClickAway( () => { setCounter((s) => s + 1); diff --git a/packages/hooks/src/useClickAway/demo/demo5.tsx b/packages/hooks/src/useClickAway/demo/demo5.tsx index 26758e0cbe..78a1f443fe 100644 --- a/packages/hooks/src/useClickAway/demo/demo5.tsx +++ b/packages/hooks/src/useClickAway/demo/demo5.tsx @@ -11,7 +11,7 @@ import { useClickAway } from 'ahooks'; export default () => { const [counter, setCounter] = useState(0); - const ref = useRef(); + const ref = useRef(null); useClickAway( () => { setCounter((s) => s + 1); diff --git a/packages/hooks/src/useDrop/demo/demo1.tsx b/packages/hooks/src/useDrop/demo/demo1.tsx index 2eabf142fe..bcbf2032b7 100644 --- a/packages/hooks/src/useDrop/demo/demo1.tsx +++ b/packages/hooks/src/useDrop/demo/demo1.tsx @@ -10,7 +10,7 @@ import React, { useRef, useState } from 'react'; import { useDrop, useDrag } from 'ahooks'; const DragItem = ({ data }) => { - const dragRef = useRef(); + const dragRef = useRef(null); const [dragging, setDragging] = useState(false); @@ -42,7 +42,7 @@ const DragItem = ({ data }) => { export default () => { const [isHovering, setIsHovering] = useState(false); - const dropRef = useRef(); + const dropRef = useRef(null); useDrop(dropRef, { onText: (text, e) => { diff --git a/packages/hooks/src/useEventListener/demo/demo1.tsx b/packages/hooks/src/useEventListener/demo/demo1.tsx index 2b1b647667..a404b56337 100644 --- a/packages/hooks/src/useEventListener/demo/demo1.tsx +++ b/packages/hooks/src/useEventListener/demo/demo1.tsx @@ -11,7 +11,7 @@ import { useEventListener } from 'ahooks'; export default () => { const [value, setValue] = useState(0); - const ref = useRef(); + const ref = useRef(null); useEventListener( 'click', diff --git a/packages/hooks/src/useExternal/demo/demo1.tsx b/packages/hooks/src/useExternal/demo/demo1.tsx index c794484c72..b12f8dda5b 100644 --- a/packages/hooks/src/useExternal/demo/demo1.tsx +++ b/packages/hooks/src/useExternal/demo/demo1.tsx @@ -22,7 +22,7 @@ export default () => { Status: {status}

- Response: {status === 'ready' ? TEST_SCRIPT?.start() : '-'} + Response: {status === 'ready' ? window.TEST_SCRIPT?.start() : '-'}

); diff --git a/packages/hooks/src/useFocusWithin/demo/demo1.tsx b/packages/hooks/src/useFocusWithin/demo/demo1.tsx index 6e654bebea..5482cdcb6d 100644 --- a/packages/hooks/src/useFocusWithin/demo/demo1.tsx +++ b/packages/hooks/src/useFocusWithin/demo/demo1.tsx @@ -11,7 +11,7 @@ import { useFocusWithin } from 'ahooks'; import { message } from 'antd'; export default () => { - const ref = useRef(); + const ref = useRef(null); const isFocusWithin = useFocusWithin(ref, { onFocus: () => { message.info('focus'); diff --git a/packages/hooks/src/useFullscreen/demo/demo1.tsx b/packages/hooks/src/useFullscreen/demo/demo1.tsx index 30c5f6f09f..e16de570da 100644 --- a/packages/hooks/src/useFullscreen/demo/demo1.tsx +++ b/packages/hooks/src/useFullscreen/demo/demo1.tsx @@ -10,7 +10,7 @@ import React, { useRef } from 'react'; import { useFullscreen } from 'ahooks'; export default () => { - const ref = useRef(); + const ref = useRef(null); const [isFullscreen, { enterFullscreen, exitFullscreen, toggleFullscreen }] = useFullscreen(ref); return (
diff --git a/packages/hooks/src/useHistoryTravel/demo/demo2.tsx b/packages/hooks/src/useHistoryTravel/demo/demo2.tsx index 2a2ac1e940..060d7a0d3a 100644 --- a/packages/hooks/src/useHistoryTravel/demo/demo2.tsx +++ b/packages/hooks/src/useHistoryTravel/demo/demo2.tsx @@ -10,9 +10,16 @@ import { useHistoryTravel } from 'ahooks'; import React, { useState } from 'react'; export default () => { - const { value, setValue, backLength, forwardLength, back, forward, go, reset } = useHistoryTravel( - ['do homework'], - ); + const { + value = [], + setValue, + backLength, + forwardLength, + back, + forward, + go, + reset, + } = useHistoryTravel(['do homework']); const [inputValue, setInputValue] = useState(''); const [step, setStep] = useState(-1); diff --git a/packages/hooks/src/useHover/demo/demo1.tsx b/packages/hooks/src/useHover/demo/demo1.tsx index 0718e9e446..36ffb0fb4d 100644 --- a/packages/hooks/src/useHover/demo/demo1.tsx +++ b/packages/hooks/src/useHover/demo/demo1.tsx @@ -10,7 +10,7 @@ import React, { useRef } from 'react'; import { useHover } from 'ahooks'; export default () => { - const ref = useRef(); + const ref = useRef(null); const isHovering = useHover(ref); return
{isHovering ? 'hover' : 'leaveHover'}
; }; diff --git a/packages/hooks/src/useInViewport/demo/demo1.tsx b/packages/hooks/src/useInViewport/demo/demo1.tsx index 4533cf6b9b..fc518cf312 100644 --- a/packages/hooks/src/useInViewport/demo/demo1.tsx +++ b/packages/hooks/src/useInViewport/demo/demo1.tsx @@ -10,7 +10,7 @@ import React, { useRef } from 'react'; import { useInViewport } from 'ahooks'; export default () => { - const ref = useRef(); + const ref = useRef(null); const [inViewport] = useInViewport(ref); return (
diff --git a/packages/hooks/src/useInfiniteScroll/demo/mutate.tsx b/packages/hooks/src/useInfiniteScroll/demo/mutate.tsx index 59db1fb7e7..73c6c97d70 100644 --- a/packages/hooks/src/useInfiniteScroll/demo/mutate.tsx +++ b/packages/hooks/src/useInfiniteScroll/demo/mutate.tsx @@ -46,9 +46,11 @@ export default () => { } = useRequest(deleteItem, { manual: true, onSuccess: (_, [id]) => { - const index = data.list.findIndex((i) => i === id); - data.list.splice(index, 1); - mutate({ ...data }); + if (data) { + const index = data.list.findIndex((i) => i === id); + data?.list.splice(index, 1); + mutate({ ...data }); + } }, }); diff --git a/packages/hooks/src/useInfiniteScroll/demo/scroll.tsx b/packages/hooks/src/useInfiniteScroll/demo/scroll.tsx index 167a18f632..d0a04643e8 100644 --- a/packages/hooks/src/useInfiniteScroll/demo/scroll.tsx +++ b/packages/hooks/src/useInfiniteScroll/demo/scroll.tsx @@ -27,7 +27,7 @@ function getLoadMoreList(nextId: string | undefined, limit: number): Promise { - const ref = useRef(); + const ref = useRef(null); const { data, loading, loadMore, loadingMore, noMore } = useInfiniteScroll( (d) => getLoadMoreList(d?.nextId, 4), diff --git a/packages/hooks/src/useInterval/demo/demo2.tsx b/packages/hooks/src/useInterval/demo/demo2.tsx index 8299551052..7780e641b5 100644 --- a/packages/hooks/src/useInterval/demo/demo2.tsx +++ b/packages/hooks/src/useInterval/demo/demo2.tsx @@ -11,7 +11,7 @@ import { useInterval } from 'ahooks'; export default () => { const [count, setCount] = useState(0); - const [interval, setInterval] = useState(1000); + const [interval, setInterval] = useState(1000); useInterval(() => { setCount(count + 1); diff --git a/packages/hooks/src/useKeyPress/demo/demo5.tsx b/packages/hooks/src/useKeyPress/demo/demo5.tsx index 946d421cd5..6fc5536a75 100644 --- a/packages/hooks/src/useKeyPress/demo/demo5.tsx +++ b/packages/hooks/src/useKeyPress/demo/demo5.tsx @@ -13,7 +13,7 @@ import React, { useState, useRef } from 'react'; import { useKeyPress } from 'ahooks'; export default () => { - const inputRef = useRef(); + const inputRef = useRef(null); const [text, setText] = useState(''); const [textRef, setTextRef] = useState(''); diff --git a/packages/hooks/src/useLongPress/demo/demo1.tsx b/packages/hooks/src/useLongPress/demo/demo1.tsx index 15ed62a43f..9a83291b4d 100644 --- a/packages/hooks/src/useLongPress/demo/demo1.tsx +++ b/packages/hooks/src/useLongPress/demo/demo1.tsx @@ -11,7 +11,7 @@ import { useLongPress } from 'ahooks'; export default () => { const [counter, setCounter] = useState(0); - const ref = useRef(); + const ref = useRef(null); useLongPress(() => setCounter((s) => s + 1), ref); diff --git a/packages/hooks/src/useLongPress/demo/demo2.tsx b/packages/hooks/src/useLongPress/demo/demo2.tsx index c5d63e62fb..dadee3a1e6 100644 --- a/packages/hooks/src/useLongPress/demo/demo2.tsx +++ b/packages/hooks/src/useLongPress/demo/demo2.tsx @@ -5,7 +5,7 @@ export default () => { const [pressCounter, setPressCounter] = useState(0); const [clickCounter, setClickCounter] = useState(0); - const ref = useRef(); + const ref = useRef(null); useLongPress(() => setPressCounter((s) => s + 1), ref, { onClick: () => setClickCounter((s) => s + 1), diff --git a/packages/hooks/src/useMouse/demo/demo2.tsx b/packages/hooks/src/useMouse/demo/demo2.tsx index a3097c18a0..338f25a690 100644 --- a/packages/hooks/src/useMouse/demo/demo2.tsx +++ b/packages/hooks/src/useMouse/demo/demo2.tsx @@ -10,7 +10,7 @@ import React, { useRef } from 'react'; import { useMouse } from 'ahooks'; export default () => { - const ref = useRef(); + const ref = useRef(null); const mouse = useMouse(ref.current); return ( diff --git a/packages/hooks/src/usePagination/demo/demo4.tsx b/packages/hooks/src/usePagination/demo/demo4.tsx index 678f0a1bdc..c829ce9145 100644 --- a/packages/hooks/src/usePagination/demo/demo4.tsx +++ b/packages/hooks/src/usePagination/demo/demo4.tsx @@ -74,7 +74,7 @@ const PaginationComponent = () => { run( { current: 1, - pageSize: params[0]?.pageSize, + pageSize: params[0]?.pageSize || 10, }, gender, ); diff --git a/packages/hooks/src/useReactive/demo/demo2.tsx b/packages/hooks/src/useReactive/demo/demo2.tsx index 4b84cbca53..9e72f1ab0d 100644 --- a/packages/hooks/src/useReactive/demo/demo2.tsx +++ b/packages/hooks/src/useReactive/demo/demo2.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { useReactive } from 'ahooks'; export default () => { - const state = useReactive({ + const state = useReactive<{ arr: number[] }>({ arr: [], }); diff --git a/packages/hooks/src/useRequest/doc/basic/demo/formatResult.tsx b/packages/hooks/src/useRequest/doc/basic/demo/formatResult.tsx deleted file mode 100644 index 79ada1e3e7..0000000000 --- a/packages/hooks/src/useRequest/doc/basic/demo/formatResult.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { useRequest } from 'ahooks'; -import Mock from 'mockjs'; -import React from 'react'; - -function getUsername(): Promise<{ username: string }> { - return new Promise((resolve) => { - setTimeout(() => { - resolve({ - username: Mock.mock('@name'), - }); - }, 1000); - }); -} - -export default () => { - const { data, loading } = useRequest(getUsername, { - formatResult: (res) => res.username, - }); - - if (loading) { - return
loading...
; - } - return
Username: {data}
; -}; diff --git a/packages/hooks/src/useRequest/doc/basic/demo/params.tsx b/packages/hooks/src/useRequest/doc/basic/demo/params.tsx index ca039a138d..da3763468e 100644 --- a/packages/hooks/src/useRequest/doc/basic/demo/params.tsx +++ b/packages/hooks/src/useRequest/doc/basic/demo/params.tsx @@ -2,7 +2,7 @@ import { useRequest } from 'ahooks'; import Mock from 'mockjs'; import React, { useState } from 'react'; -function getUsername(id: number): Promise { +function getUsername(id: string): Promise { return new Promise((resolve) => { setTimeout(() => { resolve(Mock.mock('@name')); @@ -19,7 +19,7 @@ export default () => { run, params, } = useRequest(getUsername, { - defaultParams: [1], + defaultParams: ['1'], }); const onChange = () => { diff --git a/packages/hooks/src/useSize/demo/demo1.tsx b/packages/hooks/src/useSize/demo/demo1.tsx index 2742ebee5f..d81874ae18 100644 --- a/packages/hooks/src/useSize/demo/demo1.tsx +++ b/packages/hooks/src/useSize/demo/demo1.tsx @@ -10,7 +10,7 @@ import React, { useRef } from 'react'; import { useSize } from 'ahooks'; export default () => { - const ref = useRef(); + const ref = useRef(null); const size = useSize(ref); return (
diff --git a/packages/hooks/src/useTextSelection/demo/demo3.tsx b/packages/hooks/src/useTextSelection/demo/demo3.tsx index 5226abe405..a9a7c26942 100644 --- a/packages/hooks/src/useTextSelection/demo/demo3.tsx +++ b/packages/hooks/src/useTextSelection/demo/demo3.tsx @@ -10,7 +10,7 @@ import React, { useRef } from 'react'; import { useTextSelection } from 'ahooks'; export default () => { - const ref = useRef(); + const ref = useRef(null); const selection = useTextSelection(ref); return (
diff --git a/packages/hooks/src/useVirtualList/demo/demo1.tsx b/packages/hooks/src/useVirtualList/demo/demo1.tsx index 242d608353..e825fca182 100644 --- a/packages/hooks/src/useVirtualList/demo/demo1.tsx +++ b/packages/hooks/src/useVirtualList/demo/demo1.tsx @@ -10,8 +10,8 @@ import React, { useMemo, useRef } from 'react'; import { useVirtualList } from 'ahooks'; export default () => { - const containerRef = useRef(); - const wrapperRef = useRef(); + const containerRef = useRef(null); + const wrapperRef = useRef(null); const originalList = useMemo(() => Array.from(Array(99999).keys()), []); diff --git a/packages/hooks/src/useVirtualList/demo/demo2.tsx b/packages/hooks/src/useVirtualList/demo/demo2.tsx index 4d44fad024..666fd41aa3 100644 --- a/packages/hooks/src/useVirtualList/demo/demo2.tsx +++ b/packages/hooks/src/useVirtualList/demo/demo2.tsx @@ -10,8 +10,8 @@ import React, { useMemo, useRef } from 'react'; import { useVirtualList } from 'ahooks'; export default () => { - const containerRef = useRef(); - const wrapperRef = useRef(); + const containerRef = useRef(null); + const wrapperRef = useRef(null); const originalList = useMemo(() => Array.from(Array(99999).keys()), []); diff --git a/packages/hooks/tsconfig.pro.json b/packages/hooks/tsconfig.pro.json new file mode 100644 index 0000000000..e1d263d634 --- /dev/null +++ b/packages/hooks/tsconfig.pro.json @@ -0,0 +1,6 @@ +{ + "extends": "../../tsconfig.pro.json", + "compilerOptions": { + "rootDir": "src" + } +} diff --git a/packages/use-url-state/tsconfig.pro.json b/packages/use-url-state/tsconfig.pro.json new file mode 100644 index 0000000000..e1d263d634 --- /dev/null +++ b/packages/use-url-state/tsconfig.pro.json @@ -0,0 +1,6 @@ +{ + "extends": "../../tsconfig.pro.json", + "compilerOptions": { + "rootDir": "src" + } +} diff --git a/tsconfig.json b/tsconfig.json index db69e383ef..97eba1098e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,18 +3,20 @@ "target": "ES5", "moduleResolution": "node", "jsx": "react", - "allowJs": true, "esModuleInterop": true, "downlevelIteration": true, "sourceMap": true, "baseUrl": ".", "paths": { - "@/*": ["src/*"] + "@/*": ["src/*"], + "ahooks": ["./packages/hooks/src/index.ts"], + "ahooks/lib/*": ["./packages/hooks/src/*"], + "@ahooksjs/use-url-state": ["./packages/use-url-state/src/index.ts"] }, "allowSyntheticDefaultImports": true, "skipLibCheck": true, "declaration": false, "strictNullChecks": true }, - "exclude": ["node_modules", "lib", "es", "dist", "**/__tests__", "**/__test__", "**/demo"] + "exclude": ["node_modules", "lib", "es", "dist", "example"] } diff --git a/tsconfig.pro.json b/tsconfig.pro.json new file mode 100644 index 0000000000..ab68c6817a --- /dev/null +++ b/tsconfig.pro.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.json", + "exclude": [ + "node_modules", + "lib", + "es", + "dist", + "**/__tests__", + "**/__test__", + "**/demo", + "example", + "gulpfile.js" + ] +}