Attempting to create a TypeScript declaration file for a given JavaScript library
my_lib.js :
function sum(a, b) {
return a + b;
}
function difference(a, b) {
return a - b;
}
module.exports = {
sum: sum,
difference: difference
}
my_lib.d.ts
declare module 'my_lib' {
function sum(a: number, b: number): number;
function difference(a: number, b: number): number;
export default {
sum: sum,
difference: difference
}
}
A TypeScript file attempting to utilize the library with
import my_lib from 'my_lib';
Encountering the following error message:
Error TS2656: Exported external package typings file 'C:/.../my_lib.d.ts' is not a module. Please contact the package author to update the package definition.
Any suggestions on how to resolve this issue? Thank you