From ab2dd3108730951e3cf9d41fcc729e652f5e3aee Mon Sep 17 00:00:00 2001 From: ztplz Date: Sat, 12 Jan 2019 19:22:06 +0800 Subject: [PATCH] Add types for warning --- components/_util/warning.tsx | 4 ++-- components/drawer/index.tsx | 2 +- components/select/index.tsx | 2 +- package.json | 1 + typings/custom-typings.d.ts | 2 -- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/components/_util/warning.tsx b/components/_util/warning.tsx index 6a9f7a59c6..6e29252487 100644 --- a/components/_util/warning.tsx +++ b/components/_util/warning.tsx @@ -1,6 +1,6 @@ -import warning from 'warning'; +import * as warning from 'warning'; -const warned: { [msg: string]: boolean } = {}; +const warned: Record = {}; export default (valid: boolean, message: string): void => { if (!valid && !warned[message]) { warning(false, message); diff --git a/components/drawer/index.tsx b/components/drawer/index.tsx index c302170ac9..ac18a9ab0e 100644 --- a/components/drawer/index.tsx +++ b/components/drawer/index.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import * as PropTypes from 'prop-types'; import RcDrawer from 'rc-drawer'; import createReactContext, { Context } from 'create-react-context'; -import warning from 'warning'; +import * as warning from 'warning'; import classNames from 'classnames'; import Icon from '../icon'; import { withConfigConsumer, ConfigConsumerProps } from '../config-provider'; diff --git a/components/select/index.tsx b/components/select/index.tsx index 29d7b7ae1a..14d1eda2bd 100755 --- a/components/select/index.tsx +++ b/components/select/index.tsx @@ -4,7 +4,7 @@ import RcSelect, { Option, OptGroup } from 'rc-select'; import classNames from 'classnames'; import { ConfigConsumer, ConfigConsumerProps, RenderEmptyHandler } from '../config-provider'; import omit from 'omit.js'; -import warning from 'warning'; +import * as warning from 'warning'; import Icon from '../icon'; import { tuple } from '../_util/type'; diff --git a/package.json b/package.json index 2c70e9e51c..8db428459d 100644 --- a/package.json +++ b/package.json @@ -98,6 +98,7 @@ "@types/react-dom": "^16.0.11", "@types/react-intl": "^2.3.14", "@types/react-slick": "^0.23.2", + "@types/warning": "^3.0.0", "@yesmeck/offline-plugin": "^5.0.5", "ansi-styles": "^3.2.1", "antd-theme-generator": "^1.1.4", diff --git a/typings/custom-typings.d.ts b/typings/custom-typings.d.ts index 8449ff9c8f..0f9c90c2ed 100644 --- a/typings/custom-typings.d.ts +++ b/typings/custom-typings.d.ts @@ -14,8 +14,6 @@ declare module 'rc-util*'; declare module 'shallowequal'; -declare module 'warning'; - declare module 'css-animation*'; declare module 'rc-select';