When building a TypeScript library on top of Casbin and its MongooseAdapter, a TS2309 error is thrown failing the building process.
This is cause by the export = MongooseAdapter
in the index.ts
file.
Steps to reproduce:
# Install all dependencies
yarn
# Run `tsc` to output in the `dist/` dir
yarn build
The export = MongooseAdapter
override all other named exports.
This is clear from the transpiled JavaScript code:
// transpiled casbin-mongoose-adapter
// > The last `module.exports` overrides all other `exports`.
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
const adapter_1 = require("./adapter");
__exportStar(require("./model"), exports);
__exportStar(require("./errors"), exports);
__exportStar(require("./adapter"), exports);
module.exports = adapter_1.MongooseAdapter;
Steps to reproduce:
# Install all dependencies
yarn
# Run `tsc` to output in the `dist/` dir
yarn start