react-infinite-scroller
react-infinite-scroller copied to clipboard
Typescript definition error
Hey There's a mismatch between the typescript definition and the actual code
Environment:
[email protected]
[email protected]
[email protected]
@types/[email protected]
[email protected]
As written at the documentation:
import InfiniteScroll from 'react-infinite-scroller';
But it returns undefined
console.log(InfiniteScroll); //undefined
Instead, when I'm trying to do
import * as InfiniteScroll from 'react-infinite-scroller';
console.log(InfiniteScroll) //Good
But then typescript compiler breaks with the error
[ts] Module '"/node_modules/@types/\react-infinite-scroller/index"' resolves to a non-module entity and cannot be imported using this construct.
How can this be fixed? thanks!
@KromDaniel I got the same error. You need to import using require:
import InfiniteScroll = require('react-infinite-scroller');
TypeScript does not support the import X from 'X' syntax for modules exported using export = X. See TypeScript/issues/6809
@markusjohnsson Yea I did some ugly workaround, not near my code by something like
import * as InfiniteScrollTypes from "react-infinite-scroll"
const InfiniteScroll = require("react-infinite-scroller") as InfiniteScrollTypes //For the ts definitions
This is really a bug for the types page isn't it? https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-infinite-scroller