1

I'm using declaration: true as part of my TypeScript configuration. It generates the correct types for this component, but I wanted to overwrite it. How would I go about doing that?

// Button.tsx

export const Button: React.FC<{
  className: string;
  text: string
}> = ({ className, text }) => (
  <button class={className}>
    {text}
  </button>
)

What I've already tried was to place an adjacent index.d.ts file in this directory. I thought because of how definition files were resoluted, it would overwrite the export from Button.tsx:

// index.d.ts

export { default } from "./Button";

It references this type definition that I have in this folder as well:

// Button.d.ts
declare const Button: any;
export default Button;

However, this does not work. Instead, I get the types that I defined from Button.tsx - how can I overwrite this type myself?

John Doe
  • 399
  • 1
  • 4
  • 23
seasick
  • 1,094
  • 2
  • 15
  • 29
  • [may be this answer will help you](https://stackoverflow.com/questions/41285211/overriding-interface-property-type-defined-in-typescript-d-ts-file) – Danish Nov 05 '19 at 08:29

0 Answers0