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
util typescript #1328
Merged
Merged
util typescript #1328
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
32cf0b0
refactor(util): move to ts files
danethurber 7e20cef
refactor(util): convert a few files to ts
danethurber da359df
ci: lint ignore dist ts
danethurber 324159e
fix(util): bad import path
danethurber 04d8367
style(verticaltabs): update typing signature
danethurber b57e56a
fix(util): call canUseDom in portal creation fn
danethurber 3faaa9a
Merge branch 'master' into refactor/util-ts
danethurber a5c10ad
test(util): also tsc when testing
danethurber 784ce4c
test(util): fix ts error in snapshot config
danethurber 9899684
feat(util): deprecate prop-type utils
danethurber 811ee18
fix(util): update ref typings
danethurber 8285652
feat(actionmenu): update failing ref typings
danethurber 51703f8
feat(dropdown): update failing ref typings
danethurber adbef7a
Merge branch 'refactor/util-ts' of github.com:pluralsight/design-syst…
danethurber 88e5e6e
Merge branch 'master' into refactor/util-ts
danethurber 1cb1946
refactor(util): strict type ref hooks
danethurber 96b7176
refactor(util): strict type menu keys
danethurber 084dd98
refactor(util): strict ts
danethurber 9c44d39
Merge branch 'master' into refactor/util-ts
danethurber c0eb3e6
style(radio): fix util typing
danethurber 16d1442
Merge branch 'master' into refactor/util-ts
danethurber File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import path from 'path' | ||
import initStoryshots from '@storybook/addon-storyshots' | ||
|
||
initStoryshots({ | ||
configPath: path.resolve(__dirname, '../../.storybook'), | ||
framework: 'react' | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/util/src/__specs__/styles.spec.js → packages/util/src/__specs__/styles.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 28 additions & 22 deletions
50
...l/src/__specs__/use-combined-refs.spec.js → .../src/__specs__/use-combined-refs.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,68 @@ | ||
/* eslint-disable react/prop-types */ | ||
import { renderHook } from '@testing-library/react-hooks' | ||
import { createRef, useImperativeHandle, useCallback, useState } from 'react' | ||
import { useRef, useImperativeHandle, useCallback, useState } from 'react' | ||
|
||
import { useCombinedRefs } from '..' | ||
|
||
describe('useCombinedRefs', () => { | ||
test('multiple refs', () => { | ||
const { result } = renderHook(() => { | ||
const outer = createRef() | ||
const inner = createRef() | ||
const combinedRef = useCombinedRefs(outer, inner) | ||
useImperativeHandle(combinedRef, () => ({ | ||
const outer = useRef<HTMLElement>(null) | ||
const inner = useRef<HTMLElement>(null) | ||
const combinedRef = useCombinedRefs(inner, outer) | ||
|
||
useImperativeHandle<unknown, unknown>(combinedRef, () => ({ | ||
value: 'ref' | ||
})) | ||
|
||
return { outer, inner } | ||
}) | ||
expect(result.current.outer).toEqual({ current: { value: 'ref' } }) | ||
expect(result.current.inner).toEqual({ current: { value: 'ref' } }) | ||
}) | ||
|
||
test('one ref', () => { | ||
const { result } = renderHook(() => { | ||
const outer = createRef() | ||
const inner = createRef() | ||
const outer = useRef<HTMLElement>(null) | ||
const inner = useRef<HTMLElement>(null) | ||
const combinedRef = useCombinedRefs(outer) | ||
useImperativeHandle(combinedRef, () => ({ | ||
|
||
useImperativeHandle<unknown, unknown>(combinedRef, () => ({ | ||
value: 'ref' | ||
})) | ||
|
||
return { outer, inner } | ||
}) | ||
expect(result.current.outer).toEqual({ current: { value: 'ref' } }) | ||
expect(result.current.inner).toEqual({ current: null }) | ||
}) | ||
|
||
test('no refs', () => { | ||
const { result } = renderHook(() => { | ||
const outer = createRef() | ||
const inner = createRef() | ||
const outer = useRef<HTMLElement>(null) | ||
const inner = useRef<HTMLElement>(null) | ||
const combinedRef = useCombinedRefs() | ||
useImperativeHandle(combinedRef, () => ({ | ||
|
||
useImperativeHandle<unknown, unknown>(combinedRef, () => ({ | ||
value: 'ref' | ||
})) | ||
|
||
return { outer, inner } | ||
}) | ||
|
||
expect(result.current.outer).toEqual({ current: null }) | ||
expect(result.current.inner).toEqual({ current: null }) | ||
}) | ||
test('callbackRef', () => { | ||
|
||
test('with a callback ref', () => { | ||
const { result } = renderHook(() => { | ||
const [height, setHeight] = useState(0) | ||
const outer = createRef() | ||
const inner = useCallback(node => { | ||
if (node !== null) { | ||
setHeight(5) | ||
} | ||
}, []) | ||
useCombinedRefs(inner, outer) | ||
return { height, outer } | ||
const cbRef = useCallback(() => setHeight(5), []) | ||
|
||
useCombinedRefs(cbRef) | ||
|
||
return { height } | ||
}) | ||
|
||
expect(result.current.height).toEqual(5) | ||
expect(result.current.outer).toEqual({ current: null }) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
|
||
/** | ||
* @description calls each function passed to it with the provided arguments | ||
* @param {...*} args - arguments to be called with each function | ||
*/ | ||
export const callAll = <Params extends any[]>( | ||
...fns: (Callback<Params> | undefined)[] | ||
) => (...args: Params) => { | ||
return fns.forEach(fn => fn && fn(...args)) | ||
} | ||
|
||
interface Callback<Params extends any[]> { | ||
(...args: Params): void | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not null problem for you like mine, eh? 🤷