exif-reader
exif-reader copied to clipboard
Wrong type definition export
The current export of the type definition in index.d.ts looks like this:
export default function exif(buffer: Buffer): Exif;
However, the current implementation in index.js does not export any default. The type definition should actually look like this (similar to the old type definitions):
declare function exif(buffer: Buffer): Exif;
export = exif;
or you need to adapt the exports in index.js appropriately.
When I import the library using import exifReader from 'exif-reader'; I will get following runtime error:
(0 , exif_reader_1.default) is not a function
It only works when I import and use it the following way:
import * as exifReader from 'exif-reader';
const metadata = await sharp(file).metadata();
// @ts-ignore
const exif = exifReader(metadata.exif);
(I cannot set "esModuleInterop": true in tsconfig due to some other library.)
Can confirm the same.
I found another workaround:
import exifRead from 'exif-reader';
// https://github.com/microsoft/TypeScript/issues/52086#issuecomment-1385978414
export const readExif = exifRead as unknown as typeof exifRead.default;