index.d.ts 885 B

1234567891011121314151617181920212223242526272829303132
  1. import * as React from 'react';
  2. import AuthorizedRoute, { authority } from './AuthorizedRoute';
  3. export type IReactComponent<P = any> =
  4. | React.StatelessComponent<P>
  5. | React.ComponentClass<P>
  6. | React.ClassicComponentClass<P>;
  7. type Secured = (
  8. authority: authority,
  9. error?: React.ReactNode
  10. ) => <T extends IReactComponent>(target: T) => T;
  11. type check = <T extends IReactComponent, S extends IReactComponent>(
  12. authority: authority,
  13. target: T,
  14. Exception: S
  15. ) => T | S;
  16. export interface IAuthorizedProps {
  17. authority: authority;
  18. noMatch?: React.ReactNode;
  19. }
  20. export class Authorized extends React.Component<IAuthorizedProps, any> {
  21. public static Secured: Secured;
  22. public static AuthorizedRoute: typeof AuthorizedRoute;
  23. public static check: check;
  24. }
  25. declare function renderAuthorize(currentAuthority: string): typeof Authorized;
  26. export default renderAuthorize;