slack-notify
slack-notify copied to clipboard
Could not find a declaration file for module 'slack-notify'.
Hello,
I'm having a heck of a time trying to troubleshoot this error that I'm getting that's preventing me from using slack-notify. This is what VS Code is suggesting:
Try npm i --save-dev @types/slack-notify
if it exists or add a new declaration (.d.ts) file containing declare module 'slack-notify';
ts(7016)
Nothing I've tried has resolved the issue.
Thanks.
You can use meanwhile this in a index.d.ts
file in the src
of your project:
declare module 'slack-notify' {
interface SlackNofifier {
send(args: string | SendArgs): Promise<void>;
}
interface SlackNotify extends SlackNofifier {
extend(args: string | SendArgs): SlackNofifier;
success(args: string | SendArgs): SlackNofifier;
bug(args: string | SendArgs): SlackNofifier;
alert(args: string | SendArgs): SlackNofifier;
}
interface SendArgs {
text: string;
channel?: string;
icno_url?: string;
icon_emoji?: string;
unfurl_links?: number;
username?: string;
attachments?: SendAttachment[];
fields?: { [key: string]: string }[];
}
interface SendAttachment {
fallback: string;
fields?: SendAttachmentField[];
}
interface SendAttachmentField {
title: string;
value: string;
short: boolean;
}
function SlackNotifyFactory(webhookUrl: string): SlackNotify;
export default SlackNotifyFactory;
}
please merge. it's useful
I've verified this is fixed in 2.0.3 in my projects locally using VS Code. Let me know if you see otherwise. Thank you to @matiasf9 for the help!