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

Commit c848bd4

Browse files
authored
fix(typings): enable strict mode for projects (#2323)
* fix(typings): enable strict mode for projects * fix types * add changelog entry
1 parent c8959a7 commit c848bd4

File tree

6 files changed

+21
-5
lines changed

6 files changed

+21
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
1717

1818
## [Unreleased]
1919

20+
### Fixes
21+
- Remove dependency on Lodash in TypeScript typings @layershifter ([#2323](https://github.com/microsoft/fluent-ui-react/pull/2323))
22+
2023
<!--------------------------------[ v0.44.0 ]------------------------------- -->
2124
## [v0.44.0](https://github.com/microsoft/fluent-ui-react/tree/v0.44.0) (2020-02-05)
2225
[Compare changes](https://github.com/microsoft/fluent-ui-react/compare/v0.43.2..v0.44.0)

build/gulp/tasks/test-projects/typings/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"compilerOptions": {
33
"jsx": "react",
44
"lib": ["dom", "dom.iterable", "esnext"],
5-
"target": "es5"
5+
"target": "es5",
6+
"strict": true
67
},
78
"include": ["src"]
89
}

packages/react/src/components/Carousel/Carousel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
import {
2020
WithAsProp,
2121
withSafeTypeForAs,
22+
DebounceResultFn,
2223
ShorthandCollection,
2324
ShorthandValue,
2425
ComponentEventHandler,
@@ -216,7 +217,7 @@ class Carousel extends AutoControlledComponent<WithAsProp<CarouselProps>, Carous
216217
itemRefs = [] as React.RefObject<HTMLElement>[]
217218
paddleNextRef = React.createRef<HTMLElement>()
218219
paddlePreviousRef = React.createRef<HTMLElement>()
219-
focusItemAtIndex = _.debounce((index: number) => {
220+
focusItemAtIndex: DebounceResultFn<(index: number) => void> = _.debounce((index: number) => {
220221
this.itemRefs[index].current.focus()
221222
}, 400)
222223

packages/react/src/components/Dropdown/Dropdown.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import cx from 'classnames'
77
import * as keyboardKey from 'keyboard-key'
88

99
import {
10+
DebounceResultFn,
1011
ShorthandRenderFunction,
1112
ShorthandValue,
1213
ComponentEventHandler,
@@ -1371,11 +1372,11 @@ class Dropdown extends AutoControlledComponent<WithAsProp<DropdownProps>, Dropdo
13711372
this.clearStartingString()
13721373
}
13731374

1374-
clearA11ySelectionMessage = _.debounce(() => {
1375+
clearA11ySelectionMessage: DebounceResultFn<() => void> = _.debounce(() => {
13751376
this.setState({ a11ySelectionStatus: '' })
13761377
}, Dropdown.a11yStatusCleanupTime)
13771378

1378-
clearStartingString = _.debounce(() => {
1379+
clearStartingString: DebounceResultFn<() => void> = _.debounce(() => {
13791380
this.setState({ startingString: '' })
13801381
}, Dropdown.charKeyPressedCleanupTime)
13811382
}

packages/react/src/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ import * as React from 'react'
33

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

6+
// Temporary workaround for @lodash dependency
7+
8+
export type DebounceResultFn<T> = T & {
9+
cancel: () => void
10+
flush: () => void
11+
}
12+
613
// ========================================================
714
// Utilities
815
// ========================================================

packages/react/src/utils/applyAccessibilityKeyHandlers.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import { Props, ShorthandValue } from '../types'
99
const applyAccessibilityKeyHandlers = (
1010
keyHandlers: AccessibilityHandlerProps,
1111
value: Props | ShorthandValue<Props>,
12-
) => {
12+
): Partial<Record<
13+
keyof AccessibilityHandlerProps,
14+
(e: React.KeyboardEvent, ...args: any[]) => void
15+
>> => {
1316
const valIsPropsObject = _.isPlainObject(value)
1417
const valIsReactElement = React.isValidElement(value)
1518

0 commit comments

Comments
 (0)