0%
March 23, 2022

Type Annotation Record in Typescript for 3rd-party Library and Usual Import

typescript

Include the *.d.ts file in tsconfig.json with the following content:

declare module "react-images" {
  export var Modal;
  export var ModalGateway;
  export default Carousel;
}

declare module '*.pdf' {
  const src: string;
  export default src;
}

declare module '*.md' {
  const md: string;
  export default md;
}

declare module "json-to-pretty-yaml" {
  export default { stringify(json: Object): string }
}