I have a custom module definition file for a dependency written in CoffeeScript in my typescript project.
It looks like the following and works great:
src/@types/dependency-name.d.ts
declare module 'dependency-name' {
import EventEmitter from 'eventemitter3';
/**
* omitted
*/
interface ICable {
new (channels: Record<string, ISubscription>): ICable;
channels: Record<string, ISubscription>;
channel: (name: string) => ISubscription | undefined;
setChannel: (name: string, channel: ISubscription) => ISubscription;
}
export const Cable: ICable;
}
So I want to contribute to this project and submit a type definition file.
What I tried is:
- Forked the original CoffeeScript project,
- Copied the above definition to
index.d.ts
- Add the following line to
pacakge.json
:
"typings": "index.d.ts",
- Installed forked repository in my typescript project for testing.
However, it does not recognize the added index.d.ts
file. Shows type definition is missing error.
I've seen this post and guessed that the issue is this one:
be written as external modules
But I don't understand it. Can someone guide me to convert my custom typing (module augmentation, I guess?) to correct type definition file for package.json
?