Skip to content

Commit

Permalink
fix(typescript): fix TableTooltip and LineComputedSerieDatum-type (#428)
Browse files Browse the repository at this point in the history
* fix(typescript): Fix TableTooltip and subtype on line
* fix(typescript): Fix TooltipFormatter
  • Loading branch information
johnolos authored and Raphaël Benitte committed Jan 30, 2019
1 parent 91eacdb commit fd35f78
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ declare module '@nivo/core' {

export interface TableTooltipProps {
title?: React.ReactNode
rows?: React.ReactNode[]
rows: React.ReactNode[][]
theme: Pick<Theme, 'tooltip'>
renderContent?: () => React.ReactNode
}
Expand Down
25 changes: 11 additions & 14 deletions packages/line/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ import { AxisProps } from '@nivo/axes'
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>

declare module '@nivo/line' {
export type TooltipFormatter = (
value: {
x: string | number | Date
y: string | number | Date
}
) => string
export type TooltipFormatter = (value: string | number | Date) => React.ReactNode

export interface LineDatum {
x?: string | number | Date | null
Expand All @@ -26,15 +21,17 @@ declare module '@nivo/line' {
[key: string]: any
}

export interface LineComputedSerieDatum {
position: {
x: number
y: number
}
data: LineDatum
}

export interface LineComputedSerieData {
id: string | number
data: Array<{
position: {
x: number
y: number
}
data: LineDatum
}>
data: LineComputedSerieDatum[]
color?: string
[key: string]: any
}
Expand Down Expand Up @@ -122,7 +119,7 @@ declare module '@nivo/line' {
enableStackTooltip?: boolean

tooltip?: (data: LineSliceData) => React.ReactNode
tooltipFormat?: TooltipFormatter
tooltipFormat?: TooltipFormatter | string

legends?: LegendProps[]
}
Expand Down

0 comments on commit fd35f78

Please sign in to comment.