iansinnott / react-string-replace

A simple way to safely do string replacement with React components
MIT License
652 stars 56 forks source link

TypeScript types #40

Closed MartinTichovsky closed 5 years ago

MartinTichovsky commented 5 years ago

When i install trought npm install react-string-replace, in source code isn't index.d.ts file and npm install @types/react-string-replace doesn't working.

Ksmike commented 5 years ago

+1 Can we get a resolution to this?

MartinTichovsky commented 5 years ago

Yes, create file like modules.d.ts anywhere and put this

declare module "react-string-replace" {
  function reactStringReplace(
    text: React.ReactNode,
    regex: RegExp,
    cb: (match: string, index: number) => string | JSX.Element,
  ): JSX.Element;

  export default reactStringReplace;
}
iansinnott commented 5 years ago

Types were already added in 6c71cd4, although if they are incomplete I'd welcome another PR. Just publish a new version to NPM, 0.4.2.

Please reopen if this is not resolved!

ramjak commented 5 years ago

Hi, I have downloaded v0.4.2 and it doesn't have any index.d.ts. Did you already include this file?

iansinnott commented 5 years ago

Ah I forgot to add it to files in package.json. My bad, thanks for the follow up. Published 0.4.3.