I wonder how can I use .d.ts file to local javascript files.
I know I can declare module to give a type to third-party libs.
// index.d.ts (wrote on place typeRoots)
declare module "random-joke" {
const getRandomJoke: () => Promise<any>;
export { getRandomJoke };
}
like this. so I can use this "random-joke" library with type.
but how about this? I am try to import { sum } function in index.ts
// module/utils.js
export function sum(a, b) {
return a + b;
}
export function power(a, b) {
return a ** b;
}
export function multiply(a, b) {
return a * b;
}
import { sum } from "./modules/utils";
//'sum' is declared but its value is never read.ts(6133)
//Could not find a declaration file for module './modules/utils'.
I tried declare module like this. but it doesn't works (It would have been pretty funny if this worked)
Anyway, I tried everything what I know. But the only thing that worked out was set allowJS:true in tsconfig.json
I know it isn't a right answer. then how can I make typescript get types in d.ts file in fair with javascript functions?
Even a little hint would be of great help. thanks

