digidem / react-dimensions

[Looking for maintainers]
http://lab.digital-democracy.org/react-dimensions/
450 stars 77 forks source link

Fix default export - module.exports doesn't work with TypeScript #47

Closed MathieuLorber closed 8 years ago

MathieuLorber commented 8 years ago

[Disclosure] I'm really not an expert of ES6/node module internals. I'm using react-dimensions on a project that I'm moving step-by-step to TypeScript. With the current code import Dimensions from 'react-dimensions'; will import the function as expected in ES6/Babel code, but will be undefined with TypeScript. This patch fixes the problem.

gmaclennan commented 8 years ago

import ModuleName from ... and export default is ES6 code that babel transpiles to module.exports. I'm sticking Common JS modules for now. This change would make it not work for many people.

MathieuLorber commented 8 years ago

Ok, turned out I just had to use import * as Dimensions from 'react-dimensions'; =x

BTW, I wrote a (partial) Typescript definition file, I'll probably take time to make it exhaustive & submit it to DefinitelyTyped.