Closed tvthatsme closed 5 years ago
For definitely typed? Sure sounds fine.
On Sun, Jul 22, 2018, 9:16 PM Timothy Vernon notifications@github.com wrote:
I'd like to work on this, but it would be helpful if the project included the type definitions for anyone who wants to include this in a project using typescript.
Unless you object, I will raise a PR within a day or two, ... or sooner 😃
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bvaughn/react-highlight-words/issues/60, or mute the thread https://github.com/notifications/unsubscribe-auth/AABznR1z8QNP0eAJytyzmv51mFo4g-7Kks5uJU4pgaJpZM4VaVpq .
Wait, doesn't this exist here already: https://www.npmjs.com/package/@types/react-highlight-words?
But honestly, I get errors when importing in a typescript project.
import * as Highlighter from 'react-highlight-words' // works but with warnings
import Highlighter from 'react-highlight-words' // blows up
import Highlighter from 'react-highlight-words' // doesn't work
const Highlighter = require('react-highlight-words') // works
This is how it's exported in the d.ts but it probably isn't quite right? My guess is that this snippet below is the reason why you get warnings when you try the first line in the above code.
declare class Highlighter extends React.Component<HighlighterProps> {}
export default Highlighter;
Anyone working on a fix ? I get a compilation error for import * as .. JSX element type 'Highlighter' does not have any construct or call signatures. second one doesnt work for me
TypeScript types for this lib should go to the DefinitelyTyped repo, rather than here. The "fix"would be to open a PR there. 😊
I'd like to work on this, but it would be helpful if the project included the type definitions for anyone who wants to include this in a project using typescript.
Unless you object, I will raise a PR within a day or two, ... or sooner 😃