I have a library: js and d.ts files.
How can I import them in es6 typescript file?
Javascript file
define("Calculator", ["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Calculator = /** @class */ (function () {
function Calculator() {
}
Calculator.prototype.calc = function (a) {
return a + 1;
};
return Calculator;
}());
exports.default = Calculator;
});
d.ts file
declare module "Calculator" {
export default class Calculator {
calc(a: number): number;
}
}
Typescript file with import:
import calculator = require('../libs/calculator');
Error says File '.../libs/calculator.d.ts' is not a module
question from:
https://stackoverflow.com/questions/65852919/import-amd-requirejs-javascript-file-into-typescript 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…