У меня есть метод внутри класса с именем get ()
import optionsInst from "./options";
get(url, opt: optionsInst){}
optionsInst - это интерфейс другого файла
export interface Options {
tipoRespuesta?: "json" | "arrayBuffer";
params?: string;
data?: string;
headers?: HeadersInit;
}
export default Options;
Мой tsconfig:
{
"compilerOptions": {
"target": "es6",
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"outDir": "./dist",
"module": "CommonJS",
"declaration": true,
"allowJs": true
},
"exclude": ["node_modules"]
}
Для транспорта я использую npm run build
и создается папка dist. Чтобы проверить это, я создаю новый файл и запускаю npm test.js
var CL = require("../dist/index.js");
let instancia = new CL("https://reqres.in/api/");
instancia.get("users").then(console.log);
Ошибка такая:
if (utils.isEmpty(opt.headers)) {
^
TypeError: Cannot read property 'headers' of undefined