chore: catch unhandled export as just in case

This commit is contained in:
Evan You 2023-02-06 09:02:41 +08:00
parent 37ec04b984
commit 72b570917e
1 changed files with 11 additions and 0 deletions

View File

@ -143,6 +143,17 @@ function patchTypes(pkg) {
spec.type === 'ExportSpecifier' &&
shouldRemoveExport.has(spec.local.name)
) {
// @ts-ignore
const exported = spec.exported.name
if (exported !== spec.local.name) {
// this only happens if we have something like
// type Foo
// export { Foo as Bar }
// there are no such cases atm, so it is unhandled for now.
throw new Error(
`removed export ${exported} has different local name: ${spec.local.name}`
)
}
const next = node.specifiers[i + 1]
if (next) {
// @ts-ignore