From 359e0bc0537e31bba72eb3d7ff1e34c38f26bdc2 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Wed, 5 Feb 2020 15:21:17 +0100 Subject: [PATCH 1/3] fix(typings): enable strict mode for projects --- build/gulp/tasks/test-projects/typings/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/gulp/tasks/test-projects/typings/tsconfig.json b/build/gulp/tasks/test-projects/typings/tsconfig.json index 44589f338f..91273a3039 100644 --- a/build/gulp/tasks/test-projects/typings/tsconfig.json +++ b/build/gulp/tasks/test-projects/typings/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "jsx": "react", "lib": ["dom", "dom.iterable", "esnext"], - "target": "es5" + "target": "es5", + "strict": true }, "include": ["src"] } From 3a3896662598679b493ce2bede45d684e0d87754 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 6 Feb 2020 13:52:10 +0100 Subject: [PATCH 2/3] fix types --- packages/react/src/components/Carousel/Carousel.tsx | 3 ++- packages/react/src/components/Dropdown/Dropdown.tsx | 5 +++-- packages/react/src/types.ts | 7 +++++++ packages/react/src/utils/applyAccessibilityKeyHandlers.ts | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/react/src/components/Carousel/Carousel.tsx b/packages/react/src/components/Carousel/Carousel.tsx index e1838f85dd..1dcd952b6b 100644 --- a/packages/react/src/components/Carousel/Carousel.tsx +++ b/packages/react/src/components/Carousel/Carousel.tsx @@ -19,6 +19,7 @@ import { import { WithAsProp, withSafeTypeForAs, + DebounceResultFn, ShorthandCollection, ShorthandValue, ComponentEventHandler, @@ -216,7 +217,7 @@ class Carousel extends AutoControlledComponent, Carous itemRefs = [] as React.RefObject[] paddleNextRef = React.createRef() paddlePreviousRef = React.createRef() - focusItemAtIndex = _.debounce((index: number) => { + focusItemAtIndex: DebounceResultFn<(index: number) => void> = _.debounce((index: number) => { this.itemRefs[index].current.focus() }, 400) diff --git a/packages/react/src/components/Dropdown/Dropdown.tsx b/packages/react/src/components/Dropdown/Dropdown.tsx index 7f04a31599..cb36a7e1c9 100644 --- a/packages/react/src/components/Dropdown/Dropdown.tsx +++ b/packages/react/src/components/Dropdown/Dropdown.tsx @@ -7,6 +7,7 @@ import cx from 'classnames' import * as keyboardKey from 'keyboard-key' import { + DebounceResultFn, ShorthandRenderFunction, ShorthandValue, ComponentEventHandler, @@ -1371,11 +1372,11 @@ class Dropdown extends AutoControlledComponent, 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) } diff --git a/packages/react/src/types.ts b/packages/react/src/types.ts index 576f58259d..80d54da824 100644 --- a/packages/react/src/types.ts +++ b/packages/react/src/types.ts @@ -3,6 +3,13 @@ import * as React from 'react' import { ShorthandFactory } from './utils/factories' +// Temporary workaround for @lodash dependency + +export type DebounceResultFn = T & { + cancel: () => void + flush: () => void +} + // ======================================================== // Utilities // ======================================================== diff --git a/packages/react/src/utils/applyAccessibilityKeyHandlers.ts b/packages/react/src/utils/applyAccessibilityKeyHandlers.ts index 86129ecff2..35e7458cc9 100644 --- a/packages/react/src/utils/applyAccessibilityKeyHandlers.ts +++ b/packages/react/src/utils/applyAccessibilityKeyHandlers.ts @@ -9,7 +9,10 @@ import { Props, ShorthandValue } from '../types' const applyAccessibilityKeyHandlers = ( keyHandlers: AccessibilityHandlerProps, value: Props | ShorthandValue, -) => { +): Partial void +>> => { const valIsPropsObject = _.isPlainObject(value) const valIsReactElement = React.isValidElement(value) From 21701706cb36dd9006ce79f18173e7df581d07db Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 6 Feb 2020 14:22:48 +0100 Subject: [PATCH 3/3] add changelog entry --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e06aac18db..d1384bf1c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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](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)