Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

fix(mixed): correct types to match propTypes #550

Merged
merged 8 commits into from
Dec 20, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { Grid, Ref, Segment } from '@stardust-ui/react'

const ExampleButton = React.forwardRef<HTMLButtonElement>((props, ref) => (
const ExampleButton = React.forwardRef<HTMLButtonElement, { children: string }>((props, ref) => (
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It becomes more problematic, we should force #495.

<div>
<button {...props} ref={ref} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { ShorthandValue } from '../../../../../types/utils'
import GridImagePickerItem, { GridPickerItemProps } from './GridImagePickerItem'

export interface GridPickerProps {
as?: keyof React.ReactHTML
items: GridPickerItemProps[]
gridColumns?: string | number
inputIcon?: ShorthandValue
Expand All @@ -27,7 +26,6 @@ const inputStyles = {

class GridImagePicker extends React.Component<GridPickerProps> {
static defaultProps = {
as: 'ul',
gridColumns: 5,
inputIcon: 'search',
inputPlaceholder: 'Search...',
Expand All @@ -41,7 +39,7 @@ class GridImagePicker extends React.Component<GridPickerProps> {
}

render() {
const { as: ElementType, gridColumns, inputIcon, inputPlaceholder } = this.props
const { gridColumns, inputIcon, inputPlaceholder } = this.props

return (
<>
Expand All @@ -53,7 +51,7 @@ class GridImagePicker extends React.Component<GridPickerProps> {
inputRef={this.setInputNode}
/>
<Grid
as={ElementType}
as="ul"
accessibility={gridBehavior}
columns={gridColumns}
style={gridStyles}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Image, Button } from '@stardust-ui/react'
import * as React from 'react'

export interface GridPickerItemProps {
as?: keyof React.ReactHTML
title?: string
imageSrc: string
onClick?: (e: React.SyntheticEvent, props: GridPickerItemProps) => void
Expand All @@ -17,19 +16,15 @@ const imageButtonStyles = {
}

class GridImagePickerItem extends React.Component<GridPickerItemProps> {
static defaultProps = {
as: 'li',
}

render() {
const { title, imageSrc, as: ElementType, onClick } = this.props
const { title, imageSrc, onClick } = this.props

return (
<ElementType>
<li>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This didn't make any reasonable sense, but caused my favourite error, microsoft/TypeScript#28768

<Button styles={imageButtonStyles} onClick={onClick} title={title} role="listitem">
{imageSrc && <Image src={imageSrc} fluid />}
</Button>
</ElementType>
</li>
)
}
}
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@
"@types/jest-axe": "^2.2.2",
"@types/lodash": "^4.14.118",
"@types/node": "^10.3.2",
"@types/react": "^16.3.17",
"@types/react": "^16.7.17",
"@types/react-custom-scrollbars": "^4.0.5",
"@types/react-dom": "^16.0.6",
"@types/react-dom": "^16.0.11",
"@types/react-is": "^16.5.0",
"@types/react-router": "^4.0.27",
"awesome-typescript-loader": "^5.2.1",
Expand Down Expand Up @@ -151,7 +151,7 @@
"ts-node": "^6.1.0",
"tslint": "^5.11.0",
"tslint-config-airbnb": "^5.11.1",
"typescript": "~3.1.0",
"typescript": "~3.2.2",
"webpack": "^4.25.1",
"webpack-dev-middleware": "^3.4.0",
"webpack-hot-middleware": "^2.18.2"
Expand Down
4 changes: 2 additions & 2 deletions src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { Accessibility } from '../../lib/accessibility/types'

import {
ComponentEventHandler,
Extendable,
ReactProps,
ShorthandValue,
ShorthandRenderFunction,
} from '../../../types/utils'
Expand Down Expand Up @@ -72,7 +72,7 @@ export interface AccordionProps extends UIComponentProps, ChildrenComponentProps
/**
* An accordion allows users to toggle the display of sections of content.
*/
class Accordion extends AutoControlledComponent<Extendable<AccordionProps>, any> {
class Accordion extends AutoControlledComponent<ReactProps<AccordionProps>, any> {
static displayName = 'Accordion'

static className = 'ui-accordion'
Expand Down
4 changes: 2 additions & 2 deletions src/components/Accordion/AccordionContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
ContentComponentProps,
commonPropTypes,
} from '../../lib'
import { Extendable, ComponentEventHandler } from '../../../types/utils'
import { ReactProps, ComponentEventHandler } from '../../../types/utils'

export interface AccordionContentProps
extends UIComponentProps,
Expand All @@ -31,7 +31,7 @@ export interface AccordionContentProps
/**
* A standard AccordionContent.
*/
class AccordionContent extends UIComponent<Extendable<AccordionContentProps>, any> {
class AccordionContent extends UIComponent<ReactProps<AccordionContentProps>, any> {
static displayName = 'AccordionContent'

static create: Function
Expand Down
4 changes: 2 additions & 2 deletions src/components/Accordion/AccordionTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ChildrenComponentProps,
commonPropTypes,
} from '../../lib'
import { Extendable, ComponentEventHandler } from '../../../types/utils'
import { ReactProps, ComponentEventHandler } from '../../../types/utils'

export interface AccordionTitleProps
extends UIComponentProps,
Expand All @@ -35,7 +35,7 @@ export interface AccordionTitleProps
/**
* A standard AccordionTitle.
*/
class AccordionTitle extends UIComponent<Extendable<AccordionTitleProps>, any> {
class AccordionTitle extends UIComponent<ReactProps<AccordionTitleProps>, any> {
static displayName = 'AccordionTitle'

static create: Function
Expand Down
3 changes: 2 additions & 1 deletion src/components/Animation/Animation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '../../lib'
import { AnimationProp } from '../../themes/types'
import createAnimationStyles from '../../lib/createAnimationStyles'
import { ReactPropsStrict } from '../../../types/utils'

export interface AnimationProps
extends StyledComponentProps,
Expand Down Expand Up @@ -78,7 +79,7 @@ export interface AnimationProps
/**
* An animation allows the user to animate their own components.
*/
class Animation extends UIComponent<AnimationProps, any> {
class Animation extends UIComponent<ReactPropsStrict<AnimationProps>, any> {
static create: Function

static className = 'ui-animation'
Expand Down
4 changes: 2 additions & 2 deletions src/components/Attachment/Attachment.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as PropTypes from 'prop-types'
import * as React from 'react'
import * as _ from 'lodash'
import { Extendable, ShorthandValue } from '../../../types/utils'
import { ReactProps, ShorthandValue } from '../../../types/utils'
import {
UIComponent,
customPropTypes,
Expand Down Expand Up @@ -38,7 +38,7 @@ export interface AttachmentProps extends UIComponentProps, ChildrenComponentProp
/**
* An Attachment displays a file attachment.
*/
class Attachment extends UIComponent<Extendable<AttachmentProps>, any> {
class Attachment extends UIComponent<ReactProps<AttachmentProps>, any> {
static create: Function

static className = 'ui-attachment'
Expand Down
4 changes: 2 additions & 2 deletions src/components/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from 'react'
import Image from '../Image/Image'
import Label from '../Label/Label'
import Status from '../Status/Status'
import { Extendable, ShorthandValue } from '../../../types/utils'
import { ReactProps, ShorthandValue } from '../../../types/utils'
import {
createShorthandFactory,
customPropTypes,
Expand Down Expand Up @@ -35,7 +35,7 @@ export interface AvatarProps extends UIComponentProps {
/**
* An avatar is a graphic representation of user.
*/
class Avatar extends UIComponent<Extendable<AvatarProps>, any> {
class Avatar extends UIComponent<ReactProps<AvatarProps>, any> {
static create: Function

static className = 'ui-avatar'
Expand Down
4 changes: 2 additions & 2 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Icon from '../Icon/Icon'
import Slot from '../Slot/Slot'
import { buttonBehavior } from '../../lib/accessibility'
import { Accessibility } from '../../lib/accessibility/types'
import { ComponentEventHandler, Extendable, ShorthandValue } from '../../../types/utils'
import { ComponentEventHandler, ReactProps, ShorthandValue } from '../../../types/utils'
import ButtonGroup from './ButtonGroup'

export interface ButtonProps
Expand Down Expand Up @@ -83,7 +83,7 @@ export interface ButtonState {
* - for disabled buttons, add 'disabled' attribute so that the state is properly recognized by the screen reader
* - if button includes icon only, textual representation needs to be provided by using 'title', 'aria-label', or 'aria-labelledby' attributes
*/
class Button extends UIComponent<Extendable<ButtonProps>, ButtonState> {
class Button extends UIComponent<ReactProps<ButtonProps>, ButtonState> {
static create: Function

public static displayName = 'Button'
Expand Down
4 changes: 2 additions & 2 deletions src/components/Button/ButtonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as PropTypes from 'prop-types'
import * as React from 'react'
import * as _ from 'lodash'

import { Extendable, ShorthandValue } from '../../../types/utils'
import { ReactProps, ShorthandValue } from '../../../types/utils'
import {
UIComponent,
childrenExist,
Expand All @@ -28,7 +28,7 @@ export interface ButtonGroupProps
/**
* A button group presents multiple related actions.
*/
class ButtonGroup extends UIComponent<Extendable<ButtonGroupProps>, any> {
class ButtonGroup extends UIComponent<ReactProps<ButtonGroupProps>, any> {
public static displayName = 'ButtonGroup'

public static className = 'ui-buttons'
Expand Down
4 changes: 2 additions & 2 deletions src/components/Chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as React from 'react'
import { childrenExist, customPropTypes, UIComponent, commonPropTypes } from '../../lib'
import ChatItem from './ChatItem'
import ChatMessage from './ChatMessage'
import { Extendable, ShorthandValue } from '../../../types/utils'
import { ReactProps, ShorthandValue } from '../../../types/utils'
import { Accessibility, AccessibilityActionHandlers } from '../../lib/accessibility/types'
import { chatBehavior } from '../../lib/accessibility'
import { UIComponentProps, ChildrenComponentProps } from '../../lib/commonPropInterfaces'
Expand All @@ -24,7 +24,7 @@ export interface ChatProps extends UIComponentProps, ChildrenComponentProps {
/**
* A Chat displays messages between users.
*/
class Chat extends UIComponent<Extendable<ChatProps>, any> {
class Chat extends UIComponent<ReactProps<ChatProps>, any> {
static className = 'ui-chat'

static displayName = 'Chat'
Expand Down
4 changes: 2 additions & 2 deletions src/components/Chat/ChatItem.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react'
import * as PropTypes from 'prop-types'

import { Extendable, ShorthandValue } from '../../../types/utils'
import { ReactProps, ShorthandValue } from '../../../types/utils'
import {
childrenExist,
createShorthandFactory,
Expand Down Expand Up @@ -29,7 +29,7 @@ export interface ChatItemProps extends UIComponentProps, ChildrenComponentProps
/**
* A chat item represents a single event in a chat.
*/
class ChatItem extends UIComponent<Extendable<ChatItemProps>, any> {
class ChatItem extends UIComponent<ReactProps<ChatItemProps>, any> {
static className = 'ui-chat__item'
static create: Function
static displayName = 'ChatItem'
Expand Down
4 changes: 2 additions & 2 deletions src/components/Chat/ChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
ContentComponentProps,
commonPropTypes,
} from '../../lib'
import { Extendable, ShorthandValue } from '../../../types/utils'
import { ReactProps, ShorthandValue } from '../../../types/utils'
import { chatMessageBehavior } from '../../lib/accessibility'
import { Accessibility, AccessibilityActionHandlers } from '../../lib/accessibility/types'

Expand Down Expand Up @@ -43,7 +43,7 @@ export interface ChatMessageProps
/**
* A chat message represents a single statement communicated to a user.
*/
class ChatMessage extends UIComponent<Extendable<ChatMessageProps>, any> {
class ChatMessage extends UIComponent<ReactProps<ChatMessageProps>, any> {
static className = 'ui-chat__message'

static create: Function
Expand Down
4 changes: 2 additions & 2 deletions src/components/Divider/Divider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ContentComponentProps,
commonPropTypes,
} from '../../lib'
import { Extendable } from '../../../types/utils'
import { ReactProps } from '../../../types/utils'

export interface DividerProps
extends UIComponentProps,
Expand All @@ -31,7 +31,7 @@ export interface DividerProps
/**
* A divider visually segments content into groups.
*/
class Divider extends UIComponent<Extendable<DividerProps>, any> {
class Divider extends UIComponent<ReactProps<DividerProps>, any> {
static displayName = 'Divider'

static create: Function
Expand Down
4 changes: 2 additions & 2 deletions src/components/Form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
ChildrenComponentProps,
commonPropTypes,
} from '../../lib'
import { ComponentEventHandler, Extendable, ShorthandValue } from '../../../types/utils'
import { ComponentEventHandler, ReactProps, ShorthandValue } from '../../../types/utils'
import FormField from './FormField'

export interface FormProps extends UIComponentProps, ChildrenComponentProps {
Expand All @@ -33,7 +33,7 @@ export interface FormProps extends UIComponentProps, ChildrenComponentProps {
* @accessibility
* Label needs to be provided by using 'aria-label', or 'aria-labelledby' attributes on the <form> element.
*/
class Form extends UIComponent<Extendable<FormProps>, any> {
class Form extends UIComponent<ReactProps<FormProps>, any> {
static create: Function

public static displayName = 'Form'
Expand Down
4 changes: 2 additions & 2 deletions src/components/Form/FormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
ChildrenComponentProps,
commonPropTypes,
} from '../../lib'
import { Extendable, ShorthandValue } from '../../../types/utils'
import { ReactProps, ShorthandValue } from '../../../types/utils'
import Text from '../Text/Text'
import Input from '../Input/Input'
import Slot from '../Slot/Slot'
Expand Down Expand Up @@ -44,7 +44,7 @@ export interface FormFieldProps extends UIComponentProps, ChildrenComponentProps
/**
* A field is a form element containing a label and an input.
*/
class FormField extends UIComponent<Extendable<FormFieldProps>, any> {
class FormField extends UIComponent<ReactProps<FormFieldProps>, any> {
public static displayName = 'FormField'

public static className = 'ui-form__field'
Expand Down
4 changes: 2 additions & 2 deletions src/components/Grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
commonPropTypes,
ContentComponentProps,
} from '../../lib'
import { Extendable } from '../../../types/utils'
import { ReactProps } from '../../../types/utils'
import { Accessibility } from '../../lib/accessibility/types'
import { defaultBehavior } from '../../lib/accessibility'
import ReactNode = React.ReactNode
Expand Down Expand Up @@ -38,7 +38,7 @@ export interface GridProps
* @accessibility This is example usage of the accessibility tag.
* This should be replaced with the actual description after the PR is merged
*/
class Grid extends UIComponent<Extendable<GridProps>, any> {
class Grid extends UIComponent<ReactProps<GridProps>, any> {
public static displayName = 'Grid'

public static className = 'ui-grid'
Expand Down
4 changes: 2 additions & 2 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
commonPropTypes,
} from '../../lib'
import HeaderDescription from './HeaderDescription'
import { Extendable, ShorthandValue } from '../../../types/utils'
import { ReactProps, ShorthandValue } from '../../../types/utils'

export interface HeaderProps
extends UIComponentProps,
Expand All @@ -34,7 +34,7 @@ export interface HeaderProps
* - when the description property is used in header, readers will narrate both header content and description within the element.
* In addition to that, both will be displayed in the list of headings.
*/
class Header extends UIComponent<Extendable<HeaderProps>, any> {
class Header extends UIComponent<ReactProps<HeaderProps>, any> {
static className = 'ui-header'

static displayName = 'Header'
Expand Down
4 changes: 2 additions & 2 deletions src/components/Header/HeaderDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
ContentComponentProps,
commonPropTypes,
} from '../../lib'
import { Extendable } from '../../../types/utils'
import { ReactProps } from '../../../types/utils'

export interface HeaderDescriptionProps
extends UIComponentProps,
Expand All @@ -19,7 +19,7 @@ export interface HeaderDescriptionProps
/**
* A header's description provides more detailed information.
*/
class HeaderDescription extends UIComponent<Extendable<HeaderDescriptionProps>, any> {
class HeaderDescription extends UIComponent<ReactProps<HeaderDescriptionProps>, any> {
static create: Function

static className = 'ui-header__description'
Expand Down
Loading