-
-
Notifications
You must be signed in to change notification settings - Fork 260
Open
Description
I am encountering an issue when building TypeScript declaration files (.d.ts
) using tsup
. Specifically, the generated exports1.d.ts
file contains unexpected content, which causes all types to be lost. Below are the files involved and the problem in detail:
Files:
my-exports.ts
export * as Foo from './exports1';
exports1.ts
export * from 'react/experimental';
Problem:
When building the .d.ts
files using tsup
, the generated exports1.d.ts
file contains the following code:
import * as experimental from 'react/experimental';
export * from 'react/experimental';
function _mergeNamespaces(n, m) {
m.forEach(function (e) {
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
if (k !== 'default' && !(k in n)) {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
});
return Object.freeze(n);
}
var exports1 = /*#__PURE__*/_mergeNamespaces({
__proto__: null
}, [experimental]);
export { exports1 as e };
The function _mergeNamespaces
seems to be causing the issue, where all types are lost in the process.
Expected Behavior:
I expect tsup
to generate the .d.ts
files without the _mergeNamespaces
function and without losing any type information. The file should export types correctly, preserving the structure from the original exports1.ts
.
Any Idea?
Metadata
Metadata
Assignees
Labels
No labels