node.js - Use JavaScript class in TypeScript -
i have problem introducing typescript our javascript project. first want use typescript in part of code, leaving javascript untouched.
now try use javascript class in typescript code, don't find solution in last days.
the head of typescript class import of javascript:
import { baselogic } "../baselogic"; export class claimlogic extends baselogic { ...
the javascript class ("baselogic.js"):
module.exports = class baselogic { constructor(meta, logger) { ...
my *.d.ts file ("baselogic.d.ts"):
export class baselogic { meta: any; log: any; constructor(meta: any, logger: any) }
the head of compiled javascript:
const baselogic_1 = require("../baselogic"); class claimlogic extends baselogic_1.baselogic { ...
as see in compiled javascript baselogic_1.baselogic used. results in following error:
typeerror: class extends value undefined not constructor or null
with baselogic_1 after extends keyword in javascript file fine.
i have no idea solution , hope can me!
the codesnipet in baselogic.js
exports class.
module.exports = class baselogic { constructor(meta, logger) { ... }
you try access class claimlogic extends baselogic_1.baselogic
object includes class baselogic
solution
import baselogic '../baselogic' // or: const baselogic = require("../baselogic"); class claimlogic extends baselogic { ... }
Comments
Post a Comment