warning.d.ts 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. import * as React from 'react';
  2. export declare function noop(): void;
  3. export declare function resetWarned(): void;
  4. type Warning = (valid: boolean, component: string, message?: string) => void;
  5. declare const warning: Warning;
  6. type BaseTypeWarning = (valid: boolean,
  7. /**
  8. * - deprecated: Some API will be removed in future but still support now.
  9. * - usage: Some API usage is not correct.
  10. * - breaking: Breaking change like API is removed.
  11. */
  12. type: 'deprecated' | 'usage' | 'breaking', message?: string) => void;
  13. type TypeWarning = BaseTypeWarning & {
  14. deprecated: (valid: boolean, oldProp: string, newProp: string, message?: string) => void;
  15. };
  16. export interface WarningContextProps {
  17. /**
  18. * @descCN 设置警告等级,设置 `false` 时会将废弃相关信息聚合为单条信息。
  19. * @descEN Set the warning level. When set to `false`, discard related information will be aggregated into a single message.
  20. * @since 5.10.0
  21. */
  22. strict?: boolean;
  23. }
  24. export declare const WarningContext: React.Context<WarningContextProps>;
  25. /**
  26. * This is a hook but we not named as `useWarning`
  27. * since this is only used in development.
  28. * We should always wrap this in `if (process.env.NODE_ENV !== 'production')` condition
  29. */
  30. export declare const devUseWarning: (component: string) => TypeWarning;
  31. export default warning;