Skip to content

Commit

Permalink
fix(types): make sure enum starts with declare keyword
Browse files Browse the repository at this point in the history
closes #834
  • Loading branch information
egoist committed Feb 12, 2023
1 parent 30ff79d commit a85439d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
14 changes: 1 addition & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ const getRollupConfig = async (
},
}

const fixEnumDeclaration: Plugin = {
name: 'tsup:fix-enum-declaration',
renderChunk(code) {
// make sure enum declaration starts with `declare`
// #834
return code.replace(/^(\s*)enum\s/gm, '$1declare enum ')
},
}

return {
inputConfig: {
input: dtsOptions.entry,
Expand Down Expand Up @@ -171,6 +180,7 @@ const getRollupConfig = async (
target: ts.ScriptTarget.ESNext,
},
}),
fixEnumDeclaration,
].filter(Boolean),
external: [
// Exclude dependencies, e.g. `lodash`, `lodash/get`
Expand Down

0 comments on commit a85439d

Please sign in to comment.