couds / react-bulma-components

React components for Bulma framework
MIT License
1.2k stars 126 forks source link

Runtime Error: Card importing Image instead of ImageProps interface #363

Closed RJSonnenberg closed 2 years ago

RJSonnenberg commented 3 years ago

Describe the bug When importing react-bulma-components in a React + TypeScript project with skipLibCheck set to false in the tsconfig.json project file, the project fails to compile. Below is the output after running npm start in the console:

Compiling...
Files successfully emitted, waiting for typecheck results...
Failed to compile.

C:/Code/FunRepo/React/bugtest/rbc-bug-report/node_modules/react-bulma-components/src/components/card/index.d.ts
TypeScript error in C:/Code/FunRepo/React/bugtest/rbc-bug-report/node_modules/react-bulma-components/src/components/card/index.d.ts(5,25):
'ImageProps' refers to a value, but is being used as a type here. Did you mean 'typeof ImageProps'?  TS2749

    3 |
    4 | declare const Card: BulmaComponent<{}, 'div'> & {
  > 5 |   Image: BulmaComponent<ImageProps, 'figure'>;
      |                         ^
    6 |   Content: BulmaComponent<{}, 'div'>;
    7 |   Header: BulmaComponent<{}, 'div'> & {
    8 |     Title: BulmaComponent<{}, 'div'>;

To Reproduce Steps to reproduce the behavior:

  1. Create a React + TypeScript project: npx create-react-app rbc-bug-report --template typescript
  2. Add Bulma and Bulma React Components to the project: npm install bulma bulma-react-components
  3. Open tsconfig.json in the project root directory and set skipLibCheck to false
  4. Open index.tsx in the project src directory and add import {} from 'react-bulma-components'; to the list of imports
  5. Start the app: npm start
  6. You will see the previously-mentioned error message at this point.

Expected behavior The application should compile without error when importing react-bulma-components.

Versions

Additional context I originally noticed this error in the .NET React Web App template.

Proposed Solution The ImageProps type needs to be exported: https://github.com/couds/react-bulma-components/blob/7d4d0f56979421957d26b6dc240adbf667f3d492/src/components/image/index.d.ts#L3 New:

export interface ImageProps {

We need to explicitly import the ImageProps type: https://github.com/couds/react-bulma-components/blob/7d4d0f56979421957d26b6dc240adbf667f3d492/src/components/card/index.d.ts#L2 New:

import { ImageProps } from '../image';
RJSonnenberg commented 3 years ago

This PR appears to be a different resolution from the proposed solution: https://github.com/couds/react-bulma-components/pull/360

The proposed solution is in this PR: https://github.com/couds/react-bulma-components/pull/364

kennethnym commented 2 years ago

Grouped to #362, closing