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]: Typescript – TomCreate type does not match documented usage for create setting #680

Open
CharlieIGG opened this issue Jan 20, 2024 · 1 comment
Labels
bug Something isn't working stale No activity

Comments

@CharlieIGG
Copy link

Bug description

The documentation provides the following function assignment for the create setting:

create: function(input){
	return {value:input,text:input}
}
create: function(input,callback){
	callback({value:input,text:input});
}

However, when trying to use any of these with Typescript, the type checker complains:

Type '(input: string) => { value: string; text: string; }' is not assignable to type 'boolean | TomCreate | undefined'.

Inspecting the TomCreate type:

export type TomCreate = (input: string, create: TomCreateCallback) => boolean;

Note how this is in direct conflict with the documented usage, since the docs indicate an object should be returned, whereas the type indicates that a boolean should be returned.

Expected behavior

The documentation and the type should match. Potentially, this means that the type might need to be adjusted?

Steps to reproduce

  1. Setup a project using Typescript
  2. Try to instantiate a new TomSelect with a function on the create setting:
      new TomSelect(this.element, {
            create: function (input) {
                return { value: input, text: input }
            }
        });

Additional context

"typescript": "^5.3.3"
"tom-select": "^2.3.1",

@CharlieIGG CharlieIGG added the bug Something isn't working label Jan 20, 2024
Copy link

This issue has not been active in 120 days and has been marked "stale". Remove stale label or comment or this will be closed in 15 days

@github-actions github-actions bot added the stale No activity label May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale No activity
Projects
None yet
Development

No branches or pull requests

1 participant