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

[Bug]: Too restrictive typings for TomLoadCallback #790

Open
SWICRIOT opened this issue Oct 21, 2024 · 1 comment
Open

[Bug]: Too restrictive typings for TomLoadCallback #790

SWICRIOT opened this issue Oct 21, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@SWICRIOT
Copy link

SWICRIOT commented Oct 21, 2024

Bug description

Examples for loading remote data shows the callback taking one and zero arguments. Typescript typings have defined TomLoadCallback to take two arguments : loadCallback(options: TomOption[], optgroups: TomOption[]): void;

Expected behavior

Typings should treat all parameters as optional.

Steps to reproduce

Use the following code in TypeScript

new TomSelect(accountSelect, {
    load: function (query: string, callback: TomLoadCallback)
    {
        var url = 'https://api.github.com/search/repositories?q=' + encodeURIComponent(query);
        fetch(url)
            .then(response => response.json())
            .then(json =>
            {
                callback(json.items);
            }).catch(() =>
            {
                callback();
            });
    }
});

This will show errors for the usage of callback.

Additional context

N/A

@SWICRIOT SWICRIOT added the bug Something isn't working label Oct 21, 2024
@nwalters512
Copy link
Contributor

Can you please provide a self-contained reproduction on https://www.typescriptlang.org/play and call out specifically what errors you see? Thanks!

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