Skip to content

Commit

Permalink
TypeScript: Ensure correct default export type (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
atombrenner authored Jan 14, 2025
1 parent dcc9e29 commit cc06c85
Show file tree
Hide file tree
Showing 3 changed files with 404 additions and 401 deletions.
29 changes: 15 additions & 14 deletions exiv2/generate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -86,31 +86,32 @@ const numberArrayTags = {
const generateTagGroupTypes = ([
group,
tags,
]) => `export type ${group}Tags = Record<string, GenericTag> & {
${tags
]) => ` type ${group}Tags = Record<string, GenericTag> & {
${tags
.map(([, group, tag, type]) => `${tag}: ${getType(group, tag, type)}`)
.join('\n ')}
}
`;
.join('\n ')}
}`;

const indexdts = `/**
* generated based on Exiv2 and Exif information, do not change manually
* - https://exiv2.org/tags.html
* - https://www.cipa.jp/std/documents/e/DC-008-2012_E.pdf
*/
export default function exif(buffer: Buffer): Exif;
declare function exif(buffer: Buffer): exif.Exif;
export = exif;
export type Exif = {
bigEndian: boolean
${groups.map((group) => `${group}?: Partial<${group}Tags>`).join('\n ')}
ThumbnailTags?: Partial<ImageTags>
}
declare namespace exif {
type Exif = {
bigEndian: boolean
${groups.map((group) => `${group}?: Partial<${group}Tags>`).join('\n ')}
ThumbnailTags?: Partial<ImageTags>
}
${tagGroups.map(generateTagGroupTypes).join('\n')}
${tagGroups.map(generateTagGroupTypes).join('\n\n')}
export type GenericTag = number | number[] | string | Buffer;
type GenericTag = number | number[] | string | Buffer
}
`;

writeFileSync(join(wd, '..', 'index.d.ts'), indexdts);
// console.log(indexdts);
Loading

0 comments on commit cc06c85

Please sign in to comment.