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: some ts errors #1352

Merged
merged 1 commit into from
Jun 9, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/sdk/src/cart/Cart.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PropsWithChildren } from 'react'
import React, { createContext, useMemo } from 'react'
import type { FC } from 'react'

import { useStorage } from '../storage/useStorage'
import { SDKError } from '../utils/error'
Expand Down Expand Up @@ -57,14 +57,14 @@ export interface Props {
onItemRemove?: (item?: Item) => void
}

export const CartProvider: FC<Props> = ({
export const CartProvider = ({
children,
onItemAdd,
initialCart,
onItemRemove,
onItemUpdate,
namespace: nspc = 'main',
}) => {
}: PropsWithChildren<Props>) => {
const namespace = `${nspc}::store::cart`
const [cart, setCart] = useStorage(namespace, () => ({
...initialState,
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/src/search/Provider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { FC } from 'react'
import type { PropsWithChildren } from 'react'
import React, { createContext, useMemo } from 'react'

import type { State as SearchState } from '../types'
Expand All @@ -18,12 +18,12 @@ type Props = SearchState & {
itemsPerPage: number
}

export const Provider: FC<Props> = ({
export const Provider = ({
children,
itemsPerPage,
onChange,
...rest
}) => {
}: PropsWithChildren<Props>) => {
const { state, ...searchActions } = useSearchState(rest, onChange)
const { pages, ...infiniteActions } = useSearchInfiniteState(state.page)

Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/src/ui/Provider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Dispatch, PropsWithChildren } from 'react'
import React, { createContext, useMemo, useReducer } from 'react'
import type { FC, Dispatch } from 'react'

interface BaseState {
displayMinicart: boolean
Expand Down Expand Up @@ -75,12 +75,12 @@ interface Props {

const defaultEffects: Effects = () => ({})

export const Provider: FC<Props> = ({
export const Provider = ({
children,
actions = {},
effects = defaultEffects,
initialState = {},
}) => {
}: PropsWithChildren<Props>) => {
const [state, dispatch] = useReducer(reducer(actions), {
...baseInitialState,
...initialState,
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/atoms/Slider/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const Slider = ({
const range = useRef<HTMLDivElement>(null)

const getPercent = useCallback(
(value) => Math.round(((value - min) / (max - min)) * 100),
(value: number) => Math.round(((value - min) / (max - min)) * 100),
[min, max]
)

Expand Down
16 changes: 8 additions & 8 deletions packages/ui/src/atoms/Spinner/Spinner.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { PropsWithChildren } from 'react'
import React, { forwardRef } from 'react'

export type SpinnerProps = {
Expand All @@ -7,13 +8,12 @@ export type SpinnerProps = {
testId?: string
}

const Spinner = forwardRef<HTMLDivElement, SpinnerProps>(function Spinner(
{ children, testId = 'store-spinner', ...otherProps },
ref
) {
return (
<span ref={ref} data-store-spinner data-testid={testId} {...otherProps} />
)
})
const Spinner = forwardRef<HTMLDivElement, PropsWithChildren<SpinnerProps>>(
function Spinner({ children, testId = 'store-spinner', ...otherProps }, ref) {
return (
<span ref={ref} data-store-spinner data-testid={testId} {...otherProps} />
)
}
)

export default Spinner
5 changes: 4 additions & 1 deletion packages/ui/src/molecules/Carousel/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ function Carousel({
const preRenderedSlides =
infiniteMode && children ? childrenArray.slice(childrenCount - 1) : []

const slides = preRenderedSlides.concat(children ?? [], postRenderedSlides)
const slides = preRenderedSlides.concat(
(children as any) ?? [],
postRenderedSlides
)

const slidePrevious = () => {
if (
Expand Down