Skip to content

PatternFly 4: Could not find a declaration file for module '@patternfly/react-styles' #875

@tadayosi

Description

@tadayosi

Hello,

I'm trying to develop an app with patternfly-react + typescript, using typescript-react-starter. As soon as I add a Button with the first Hello component, I get the following error while building it:

/home/tasato/projects/my-app/node_modules/@patternfly/react-core/dist/js/styles/gutters.d.ts
(1,53): Could not find a declaration file for module '@patternfly/react-styles'. '/home/tasato/projects/my-app/node_modules/@patternfly/react-styles/dist/js/index.js' implicitly has an 'any' type.
  Try `npm install @types/patternfly__react-styles` if it exists or add a new declaration (.d.ts) file containing `declare module '@patternfly/react-styles';`

Any ideas why it happens and how I can resolve it?

Here is my Hello.tsx:

import { Button } from '@patternfly/react-core';
import * as React from 'react';
import './Hello.css';
export interface IProps {
  name: string;
}
class Hello extends React.Component<IProps, object> {
  public render() {
    const { name } = this.props;
    return (
      <div className="hello">
        <div className="greeting">
          Hello {name}!
        </div>
        <Button variant="primary">Button</Button>
      </div>
    );
  }
}
export default Hello;

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions