bvaughn/react-highlight-words

Missing typescript typings

tvthatsme opened this issue ยท 4 comments

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 ๐Ÿ˜ƒ

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. ๐Ÿ˜Š