I try to create a typescript declaration file for a sample JS library
my_lib.js :
function f1(a, b) {
return a + b;
}
function f2(a, b) {
return a - b;
}
module.exports = {
f1: f1,
f2: f2
}
my_lib.d.ts
declare module 'my_lib' {
function f1(a: number, b: number): number;
function f2(a: number, b: number): number;
export default {
f1: f1,
f2: f2
}
}
A typescript file try to used the library with
import my_lib from 'my_lib';
I have this error
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 idea? Thanks