瀏覽代碼

chore: catch unhandled export as just in case

Evan You 3 年之前
父節點
當前提交
72b570917e
共有 1 個文件被更改,包括 11 次插入0 次删除
  1. 11 0
      rollup.dts.config.js

+ 11 - 0
rollup.dts.config.js

@@ -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