When compiling my code using the command
tsc --p typescript/tsconfig.json --outFile "dist/umd/index.d.ts"
, I encountered an issue.
The contents of my tsconfig.json
file are as follows:
{
"include": ["../src/**/*"],
"exclude": ["../**/*.test.ts"],
"compilerOptions": {
"target": "es2015",
"lib": ["dom", "es2017"],
"moduleResolution": "node",
"module": "amd"
}
}
However, the resulting index.d.ts
file has unexpected content, including statements like:
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
// more statements...
};
define("enums", ["require", "exports"], function (require, exports) {
// exported values...
});
// other similar definitions and exports...
Upon trying to use this file, TypeScript raised errors such as:
dist/umd/index.d.ts:1:1 - error TS1036: Statements are not allowed in ambient contexts.
This issue makes me question why TypeScript generated a file that seems incompatible with its own syntax. Why is it utilizing define
instead of export
? Additionally, an error message like:
tests/typescript/base.ts:1:30 - error TS2306: File '/Users/federicozivolo/Projects/popper.js/dist/umd/index.d.ts' is not a module.
import { createPopper } from '@popperjs/core';
If anyone can provide assistance or insights on this matter, the full source code can be found at https://github.com/popperjs/popper.js/pull/849.