zerodevx/svelte-toast

Fix typescript definitions

Closed this issue · 1 comments

Creating a new issue for this @ulfaslak - I think the handwritten src/index.d.ts needs to be updated to squelch these error hints. Unfortunately I'm not the most familiar with typescript so I'm hoping someone can help? 🆘


But I do get a TypeScript error which I think deserves your attention.

In a minimal example like this, in some ".ts" script:

import { toast } from '@zerodevx/svelte-toast';
import { get } from 'svelte/store';

get(toast)

the TypeScript linter complains over the get(toast) line, saying:

Screenshot 2022-05-23 at 06 47 30

It's was the same when I tried to implement my solution using toast.subscribe, and in fact that's also what the error is saying (that subscribe is missing). The strange thing is that when I place a debugger in my code, toast DOES have a subscribe method. And I looked into your code; it's pretty clear that the createToast returns a valid store object with a subscribe key and all.

It's not a Svelte bug I think. I tried something super simple like:

import { get, writable } from 'svelte/store';

function createCount() {
  const { subscribe, set, update } = writable(0);
  return {
    subscribe,
  };
}

let store = createCount();
get(store);

and that did not cause any linting errors.

Note: this is not a blocker, and the code runs just fine.

Originally posted by @ulfaslak in #44 (comment)

This should be fixed in v0.7.2.