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

fix(typings): enable strict mode for projects #2323

Merged
merged 4 commits into from
Feb 6, 2020
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

### Fixes
- Remove dependency on Lodash in TypeScript typings @layershifter ([#2323](https://github.com/microsoft/fluent-ui-react/pull/2323))

<!--------------------------------[ v0.44.0 ]------------------------------- -->
## [v0.44.0](https://github.com/microsoft/fluent-ui-react/tree/v0.44.0) (2020-02-05)
[Compare changes](https://github.com/microsoft/fluent-ui-react/compare/v0.43.2..v0.44.0)
Expand Down
3 changes: 2 additions & 1 deletion build/gulp/tasks/test-projects/typings/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"compilerOptions": {
"jsx": "react",
"lib": ["dom", "dom.iterable", "esnext"],
"target": "es5"
"target": "es5",
"strict": true
},
"include": ["src"]
}
3 changes: 2 additions & 1 deletion packages/react/src/components/Carousel/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import {
WithAsProp,
withSafeTypeForAs,
DebounceResultFn,
ShorthandCollection,
ShorthandValue,
ComponentEventHandler,
Expand Down Expand Up @@ -216,7 +217,7 @@ class Carousel extends AutoControlledComponent<WithAsProp<CarouselProps>, Carous
itemRefs = [] as React.RefObject<HTMLElement>[]
paddleNextRef = React.createRef<HTMLElement>()
paddlePreviousRef = React.createRef<HTMLElement>()
focusItemAtIndex = _.debounce((index: number) => {
focusItemAtIndex: DebounceResultFn<(index: number) => void> = _.debounce((index: number) => {
this.itemRefs[index].current.focus()
}, 400)

Expand Down
5 changes: 3 additions & 2 deletions packages/react/src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import cx from 'classnames'
import * as keyboardKey from 'keyboard-key'

import {
DebounceResultFn,
ShorthandRenderFunction,
ShorthandValue,
ComponentEventHandler,
Expand Down Expand Up @@ -1371,11 +1372,11 @@ class Dropdown extends AutoControlledComponent<WithAsProp<DropdownProps>, Dropdo
this.clearStartingString()
}

clearA11ySelectionMessage = _.debounce(() => {
clearA11ySelectionMessage: DebounceResultFn<() => void> = _.debounce(() => {
this.setState({ a11ySelectionStatus: '' })
}, Dropdown.a11yStatusCleanupTime)

clearStartingString = _.debounce(() => {
clearStartingString: DebounceResultFn<() => void> = _.debounce(() => {
this.setState({ startingString: '' })
}, Dropdown.charKeyPressedCleanupTime)
}
Expand Down
7 changes: 7 additions & 0 deletions packages/react/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import * as React from 'react'

import { ShorthandFactory } from './utils/factories'

// Temporary workaround for @lodash dependency

export type DebounceResultFn<T> = T & {
cancel: () => void
flush: () => void
}

// ========================================================
// Utilities
// ========================================================
Expand Down
5 changes: 4 additions & 1 deletion packages/react/src/utils/applyAccessibilityKeyHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { Props, ShorthandValue } from '../types'
const applyAccessibilityKeyHandlers = (
keyHandlers: AccessibilityHandlerProps,
value: Props | ShorthandValue<Props>,
) => {
): Partial<Record<
keyof AccessibilityHandlerProps,
(e: React.KeyboardEvent, ...args: any[]) => void
>> => {
const valIsPropsObject = _.isPlainObject(value)
const valIsReactElement = React.isValidElement(value)

Expand Down