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

Commit 3bf1f17

Browse files
committed
fix(lodash): add types and fix errors
1 parent dc4c67e commit 3bf1f17

File tree

18 files changed

+122
-61
lines changed

18 files changed

+122
-61
lines changed

build/gulp/plugins/gulp-example-menu.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as through2 from 'through2'
55
import * as Vinyl from 'vinyl'
66

77
import { parseDocSection } from './util'
8+
import { ObjectOf } from 'types/utils'
89

910
const SECTION_ORDER = {
1011
Types: 1,
@@ -22,7 +23,13 @@ const getSectionOrder = sectionName =>
2223
const pluginName = 'gulp-example-menu'
2324

2425
export default () => {
25-
const exampleFilesByDisplayName = {}
26+
const exampleFilesByDisplayName: ObjectOf<
27+
ObjectOf<{
28+
sectionName: string
29+
examples: ObjectOf<any>
30+
order: number
31+
}>
32+
> = {}
2633

2734
function bufferContents(file, enc, cb) {
2835
if (file.isNull()) {

build/gulp/plugins/util/parseDocSection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type Example = {
2525
const parseDocSection = buffer => {
2626
const ast = parseBuffer(buffer)
2727
const examples: Example[] = []
28-
let sectionName
28+
let sectionName: string
2929

3030
traverse(ast, {
3131
JSXOpeningElement: path => {

docs/src/components/ComponentDoc/ComponentProp/ComponentPropExtra.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import PropTypes from 'prop-types'
22
import * as React from 'react'
3+
import { Extendable } from 'types/utils'
4+
5+
export interface ComponentPropExtraProps {
6+
children?: JSX.Element[]
7+
title?: React.ReactNode
8+
inline?: boolean
9+
}
310

411
const descriptionStyle = {
512
color: '#666',
@@ -16,7 +23,12 @@ const contentInlineStyle = {
1623
display: 'inline',
1724
}
1825

19-
const ComponentPropExtra: any = ({ children, inline, title, ...rest }) => (
26+
const ComponentPropExtra = ({
27+
children,
28+
inline,
29+
title,
30+
...rest
31+
}: Extendable<ComponentPropExtraProps>) => (
2032
<div {...rest} style={descriptionStyle}>
2133
<strong>{title}</strong>
2234
<div style={inline ? contentInlineStyle : contentBlockStyle}>{children}</div>

docs/src/components/ComponentDoc/ComponentProp/ComponentPropFunctionSignature.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@ import PropTypes from 'prop-types'
33
import * as React from 'react'
44

55
import { neverUpdate } from 'docs/src/hoc'
6-
import ComponentPropExtra from './ComponentPropExtra'
6+
import ComponentPropExtra, { ComponentPropExtraProps } from './ComponentPropExtra'
7+
8+
interface ComponentPropFunctionSignature extends ComponentPropExtraProps {
9+
name?: string
10+
tags?: {
11+
name?: string
12+
description?: string
13+
title?: string
14+
}[]
15+
}
716

817
const descriptionStyle = {
918
flex: '5 5 0',
@@ -22,7 +31,7 @@ const rowStyle: any = {
2231

2332
const getTagType = tag => (tag.type.type === 'AllLiteral' ? 'any' : tag.type.name)
2433

25-
const ComponentPropFunctionSignature: any = ({ name, tags }) => {
34+
const ComponentPropFunctionSignature = ({ name, tags }: ComponentPropFunctionSignature) => {
2635
const params = _.filter(tags, { title: 'param' })
2736
const returns = _.find(tags, { title: 'returns' })
2837

docs/src/components/Sidebar/Sidebar.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ import { themes } from '@stardust-ui/react'
1313
import { ThemeContext } from '../../context/theme-context'
1414
import { constants } from 'src/lib'
1515

16+
type ComponentMenuItem = { displayName: string; type: string }
17+
1618
const pkg = require('../../../../package.json')
17-
const componentMenu = require('docs/src/componentMenu')
18-
const behaviorMenu = require('docs/src/behaviorMenu')
19+
const componentMenu: ComponentMenuItem[] = require('docs/src/componentMenu')
20+
const behaviorMenu: ComponentMenuItem[] = require('docs/src/behaviorMenu')
1921

2022
const selectedItemLabelStyle: any = { color: '#35bdb2', float: 'right' }
2123
const selectedItemLabel = <span style={selectedItemLabelStyle}>Press Enter</span>
22-
type ComponentMenuItem = { displayName: string; type: string }
2324

2425
class Sidebar extends React.Component<any, any> {
2526
static propTypes = {
@@ -51,7 +52,7 @@ class Sidebar extends React.Component<any, any> {
5152
this._searchInput = (findDOMNode(this) as any).querySelector('.ui.input input')
5253
}
5354

54-
handleDocumentKeyDown = e => {
55+
private handleDocumentKeyDown = e => {
5556
const code = keyboardKey.getCode(e)
5657
const isAZ = code >= 65 && code <= 90
5758
const hasModifier = e.altKey || e.ctrlKey || e.metaKey
@@ -60,20 +61,20 @@ class Sidebar extends React.Component<any, any> {
6061
if (!hasModifier && isAZ && bodyHasFocus) this._searchInput.focus()
6162
}
6263

63-
handleItemClick = () => {
64+
private handleItemClick = () => {
6465
const { query } = this.state
6566

6667
if (query) this.setState({ query: '' })
6768
if (document.activeElement === this._searchInput) this._searchInput.blur()
6869
}
6970

70-
handleSearchChange = e =>
71+
private handleSearchChange = e =>
7172
this.setState({
7273
selectedItemIndex: 0,
7374
query: e.target.value,
7475
})
7576

76-
handleSearchKeyDown = e => {
77+
private handleSearchKeyDown = e => {
7778
const { history } = this.props
7879
const { selectedItemIndex } = this.state
7980
const code = keyboardKey.getCode(e)
@@ -101,9 +102,9 @@ class Sidebar extends React.Component<any, any> {
101102
}
102103
}
103104

104-
menuItemsByType = _.map(nextType => {
105+
private menuItemsByType = _.map(nextType => {
105106
const items = _.flow(
106-
_.filter(({ type }) => type === nextType),
107+
_.filter<ComponentMenuItem>(({ type }) => type === nextType),
107108
_.map(info => (
108109
<Menu.Item
109110
key={info.displayName}
@@ -124,7 +125,7 @@ class Sidebar extends React.Component<any, any> {
124125
)
125126
}, constants.typeOrder)
126127

127-
renderSearchItems = () => {
128+
private renderSearchItems = () => {
128129
const { selectedItemIndex, query } = this.state
129130
if (!query) return undefined
130131

docs/src/examples/components/Text/Types/TextSizesExample.shorthand.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const TextSizesExampleShorthand = () => (
77
render={({ siteVariables }) => {
88
return _.map(siteVariables.fontSizes, (value, key) => (
99
<div key={key}>
10-
<Text size={key} content={`This is size="${key}" size font.`} />
10+
<Text size={key as any} content={`This is size="${key}" size font.`} />
1111
</div>
1212
))
1313
}}

docs/src/examples/components/Text/Types/TextSizesExample.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const TextSizesExample = () => (
77
render={({ siteVariables }) => {
88
return _.map(siteVariables.fontSizes, (value, key) => (
99
<div key={key}>
10-
<Text size={key}>This is size="{key}" size font.</Text>
10+
<Text size={key as any}>This is size="{key}" size font.</Text>
1111
</div>
1212
))
1313
}}

docs/src/prototypes/chatPane/services/dataMock.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ChatMock {
5858
const timestamp = getTimestamp(date)
5959

6060
const message: MessageData = {
61-
id,
61+
id: String(id),
6262
from,
6363
mine,
6464
date,
@@ -69,7 +69,7 @@ class ChatMock {
6969
}
7070

7171
return message
72-
}).sort((a, b) => a.date - b.date)
72+
}).sort((a, b) => a.date.getMilliseconds() - b.date.getMilliseconds())
7373

7474
this.chat = {
7575
id: random.uuid(),

docs/src/prototypes/chatPane/services/dateUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as _ from 'lodash'
2-
import moment from 'moment'
2+
import * as moment from 'moment'
33
import { date } from 'faker'
44

55
const getNowDate = (): Date => new Date()

docs/src/prototypes/chatPane/services/messageFactoryMock.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export enum ChatItemTypes {
1313
interface ChatItem {
1414
itemType: ChatItemTypes
1515
}
16+
1617
interface ChatMessage extends ChatMessageProps, ChatItem {
1718
tabIndex: number
1819
}
@@ -75,7 +76,7 @@ export function generateChatProps(chat: ChatData): ChatItemContentProps[] {
7576
chatProps.push(generateChatMsgProps(lastMsg, members.get(lastMsg.from)))
7677

7778
// Last read divider
78-
const myLastMsgIndex: number = _.findLastIndex(chatProps, item => item.mine)
79+
const myLastMsgIndex = _.findLastIndex(chatProps, item => (item as ChatMessage).mine)
7980
if (myLastMsgIndex < chatProps.length - 1) {
8081
chatProps.splice(
8182
myLastMsgIndex + 1,

0 commit comments

Comments
 (0)