eiriklv / react-masonry-component

A React.js component for using @desandro's Masonry
MIT License
1.44k stars 145 forks source link

Error in typings: Exports and export assignments are not permitted in module augmentations. #57

Closed empz closed 7 years ago

empz commented 7 years ago

TypeScript 2.0.3 throws the following error on typings.d.ts

...\node_modules\react-masonry-component\typings.d.ts
(31,5): error TS2666: Exports and export assignments are not permitted in module augmentations.

I don't know why this is not allowed but I'll do some research on how to workaround this problem.

empz commented 7 years ago

The problem is that the export needs to be outside the "declare module" and in order to declare a variable (Masonry) we need to use the declare keyword,

Here's the working typings.d.ts file. I guess you can just replace the contents of it. I don't think forking your project and submitting a PR is worth the trouble.

Thank you

import { ComponentClass } from "react";

declare module "react-masonry-component" {

    export interface MasonryOptions {
        columnWidth?: number;
        itemSelector?: string;
        gutter?: number;
        percentPosition?: boolean;
        stamp?: string;
        fitWidth?: boolean;
        originLeft?: boolean;
        originTop?: boolean;
        containerStyle?: Object;
        transitionDuration?: string;
        resize?: boolean;
        initLayout?: boolean;
    }

    interface MasonryPropTypes {
        disableImagesLoaded?: boolean;
        updateOnEachImageLoad?: boolean;
        onImagesLoaded?: (instance: any) => void;
        options?: MasonryOptions;
        className?: string;
        elementType?: string;
        style?: Object;
    }

}

declare const Masonry: ComponentClass<MasonryPropTypes>;
export default Masonry;
cwmoo740 commented 7 years ago

https://github.com/eiriklv/react-masonry-component/pull/59

afram commented 7 years ago

I have merged in #59 and will close this issue. Please reopen if needed