Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create .d.ts files for TypeScript #28

Open
metalmatze opened this issue Jan 11, 2021 · 5 comments
Open

Create .d.ts files for TypeScript #28

metalmatze opened this issue Jan 11, 2021 · 5 comments

Comments

@metalmatze
Copy link

Hey,

thanks for the project! 💯
Sadly my CI currently fails as it expects the types declared.

Try `npm i --save-dev @types/react-responsive-masonry` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-responsive-masonry';`

Now, I have never done this and would try to do it, however, if it an easy task for you I'd appreciate the help.
Let me know!

@abumalick
Copy link

abumalick commented Jan 25, 2021

As a quick fix, you can create a declarations.d.ts file at the root of the project and write declare module 'react-responsive-masonry'; inside this file

It should silence the error.

@popzelife
Copy link

Here is a minimalist declaration.d.ts file

declare module 'react-responsive-masonry' {
  import * as React from 'react';

  const Masonry: React.FC<{
    columnsCount?: number
    gutter?: string
  }>

  export const ResponsiveMasonry: React.FC<{
    columnsCountBreakPoints?: Record<number, number>
  }>

  export default Masonry
}

@CodeAunt
Copy link

Put it inside the 'src' folder if you're using React

@bruxr
Copy link

bruxr commented Feb 3, 2023

In addition to @popzelife's declaration file, you can add additional props to support styling:

import React, { CSSProperties } from 'react'

const Masonry: React.FC<{
  columnsCount?: number
  gutter?: string
  className?: string
  style?: CSSProperties
}>

export const ResponsiveMasonry: React.FC<{
  columnsCountBreakPoints?: Record<number, number>
  className?: string
  style?: CSSProperties
}>

@stevemeisner
Copy link

We can leverage @types/react-responsive-masonry, now.

Using yarn: yarn add -D @types/react-responsive-masonry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants