Skip to content

Instantly share code, notes, and snippets.

@alex3165
Last active August 31, 2016 13:17
Show Gist options
  • Save alex3165/e2bd0aefa27024b5a10d81bde508a581 to your computer and use it in GitHub Desktop.
Save alex3165/e2bd0aefa27024b5a10d81bde508a581 to your computer and use it in GitHub Desktop.
import * as React from 'react';
declare interface LoadingProps {
color? : string;
height? : any;
width? : any;
type? : string;
}
declare interface LoadingState {
delayed : boolean;
}
declare class Loading extends React.Component<LoadingProps, LoadingState> {}
declare module 'react-loading' { // invalid module name in augmentation, module 'react-loading' cannot be found
export = Loading;
}
@alex3165
Copy link
Author

And if i remove import * as React from 'react'; i can declare the module correctly

@Wykks
Copy link

Wykks commented Aug 31, 2016

/// <reference path="../typings/globals/react/index.d.ts" />

declare namespace Loading {
  interface LoadingProps {
    color? : string;
    height? : any;
    width? : any;
    type? : string;
  }

  interface LoadingState {
    delayed : boolean;
  }

  export default class Loading extends __React.Component<LoadingProps, LoadingState> {}
}

declare module 'react-loading' {
  export = Loading;
}

Usage :

import Loading from 'react-loading';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment