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(core): fix invalid core types #1386

Merged
merged 6 commits into from Apr 23, 2021
Merged
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
46 changes: 24 additions & 22 deletions packages/core/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react'
import { OpaqueInterpolation, SpringConfig } from 'react-spring'
import { Interpolation, SpringConfig } from 'react-spring'

declare module '@nivo/core' {
export type DatumValue = string | number | Date
Expand Down Expand Up @@ -208,7 +208,7 @@ declare module '@nivo/core' {
| 'stepAfter'
| 'stepBefore'

export function useAnimatedPath(path: string): OpaqueInterpolation<string>
export function useAnimatedPath(path: string): Interpolation<string>

export type LinearGradientDef = {
id: string
Expand Down Expand Up @@ -250,23 +250,25 @@ declare module '@nivo/core' {
defs: Def[]
}

export declare const defaultAnimate = true
export declare const defaultMotionStiffness = 90
export declare const defaultMotionDamping = 15
export const defaultAnimate = true
export const defaultMotionStiffness = 90
export const defaultMotionDamping = 15

export declare const motionDefaultProps = {
animate: true,
stiffness: 90,
damping: 15,
config: 'default',
type MotionDefaultProps = {
animate: true
stiffness: 90
damping: 15
config: 'default'
}
export const motionDefaultProps: MotionDefaultProps

export declare const defaultMargin = {
top: 0,
right: 0,
bottom: 0,
left: 0,
type DefaultMargin = {
top: 0
right: 0
bottom: 0
left: 0
}
export const defaultMargin: DefaultMargin

export function PatternLines(props: Omit<PatternLinesDef, 'type'>): JSX.Element
export function PatternSquares(props: Omit<PatternSquaresDef, 'type'>): JSX.Element
Expand All @@ -277,7 +279,7 @@ declare module '@nivo/core' {
export function degreesToRadians(degrees: number): number
export function radiansToDegrees(radians: number): number

type Accessor<T, U> = T extends string ? U[T] : never
type Accessor<T, U> = T extends keyof U ? U[T] : never

export type DatumPropertyAccessor<RawDatum, T> = (datum: RawDatum) => T

Expand All @@ -293,7 +295,7 @@ declare module '@nivo/core' {
outerHeight: number
}

export const SvgWrapper = (
type SvgWrapperType = (
props: React.PropsWithChildren<{
width: number
height: number
Expand All @@ -302,6 +304,7 @@ declare module '@nivo/core' {
role?: string
}>
) => JSX.Element
export const SvgWrapper: SvgWrapperType

interface ContainerProps {
theme?: Theme
Expand All @@ -313,18 +316,17 @@ declare module '@nivo/core' {
motionConfig?: string | SpringConfig
}

export const Container = (props: React.PropsWithChildren<ContainerProps>) => JSX.Element
type ContainerType = (props: React.PropsWithChildren<ContainerProps>) => JSX.Element
export const Container: ContainerType

export const ResponsiveWrapper = (props: {
type ResponsiveWrapperType = (props: {
children: (dimensions: { width: number; height: number }) => JSX.Element
}) => JSX.Element
export const ResponsiveWrapper: ResponsiveWrapperType

export function getDistance(x1: number, y1: number, x2: number, y2: number): number
export function getAngle(x1: number, y1: number, x2: number, y2: number): number

export function radiansToDegrees(radians: number): number
export function degreesToRadians(degrees: number): number

export function positionFromAngle(
angle: number,
distance: number
Expand Down