Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing type definition for bind #58

Closed
royston-c opened this issue Dec 17, 2021 · 7 comments
Closed

Missing type definition for bind #58

royston-c opened this issue Dec 17, 2021 · 7 comments
Labels
bug Something isn't working

Comments

@royston-c
Copy link

The typescript definition is missing for the bind function that can be imported using import { bind } from 'svelte-simple-modal';

This worked in: 1.0.3
Throws error in: 1.1.1

Error:

Module '"svelte-simple-modal"' has no exported member 'bind'. Did you mean to use 'import bind from "svelte-simple-modal"' instead?

I can't say exactly the version that is started to fail with but it did work with 1.0.3.

Workaround: downgrade to 1.0.3

@flekschas
Copy link
Owner

Type definitions were only added in v1.1.1. Before that they simply did not exist.

1b5bcd4
https://unpkg.com/browse/svelte-simple-modal@1.1.1/types/Modal.svelte.d.ts

Are other type annotations found?

@flekschas
Copy link
Owner

If you have the time, it'd be great if you could put together a simple test demo or share your setup for a reproducible example.

@royston-c
Copy link
Author

royston-c commented Dec 17, 2021

import type { SvelteComponent } from 'svelte';
import { writable } from 'svelte/store';
import { bind } from 'svelte-simple-modal'; // <-- This will error

export const modals = writable<{ resolver: Function, modal: any }[]>([]);

export function showModal<TResponse>(component: typeof SvelteComponent, props?: Record<string, any>): Promise<TResponse | undefined> {
    var resolver;
    var promise = new Promise<TResponse>((resolve) => resolver = resolve);
    modals.update((current) => {
        current.push({ modal: bind(component, props), resolver: resolver });
        return current;
    });

    return promise;
}

The above is a small example of the issue with v1.1.1.

Also on a side note, I was wondering if your Model.svelte.d.ts should be using SvelteComponent (from import type { SvelteComponent } from 'svelte';) instead of the untyped Component type?

@flekschas
Copy link
Owner

flekschas commented Dec 18, 2021

Thanks for the example. You're probably right about the type annotation. Unfortunately, the Modal.svelte.d.ts file is auto-generated with sveld, so fixing it manually wouldn't be a great avenue. I'll explore and see if I find a way to fix this with sveld.

@flekschas
Copy link
Owner

I've opened a ticket with Sveld to see if there's a way the type annotations can be generated properly without requiring manually creating the types.

Apart from that bind() is now properly exported in v1.1.2

@flekschas flekschas added the bug Something isn't working label Jan 1, 2022
@flekschas
Copy link
Owner

@royston-c The type def issue should finally be fixed in v1.3.1 thanks to the guys who fixed sveld. If you confirm I'll close the issue (or you can close it if you like)

@flekschas
Copy link
Owner

Closing this as I believe the issue is addressed. If it's not, please reopen. Thanks for reporting the problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants