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

[Typescript] Improving types #234

Open
jamesst20 opened this issue Jun 5, 2024 · 3 comments
Open

[Typescript] Improving types #234

jamesst20 opened this issue Jun 5, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@jamesst20
Copy link

Hi,

I have written types for myself to improve Svelecte usage in my own wrapper.

I though maybe I could share so you could see yourself if maybe this would be a great addition to be embedded into Svelecte.

Capture d’écran, le 2024-06-05 à 10 38 24

REPL

@mskocik
Copy link
Owner

mskocik commented Jun 5, 2024

I am not against it, but I don't really know what should be done.

@jamesst20
Copy link
Author

jamesst20 commented Jun 5, 2024

@mskocik

I had forgotten Svelecte was written in plain JS.

Right now, based on your JSDoc (comments like /** @type {string} */) when you run pnpm run package it generates d.ts files that provide typescript typings.

I gave a try and wrote the equivalent under jsdoc

types-jsdoc.txt

If applied properly, it should output proper d.ts file, right? I have never used jsdoc before

Not sure how you would tell that there are generics type in the component itself? Do you need to add an extra top declaration like

/**
  * @template {ItemType<Opt, TKey, VKey>} Opt
  * @template {boolean} M
  * @template {boolean} VObj
  * @template {GenericKeyType<Opt>} TKey
  * @template {GenericKeyType<Opt>} VKey
  */

?

@mskocik mskocik added the enhancement New feature or request label Jun 5, 2024
@mskocik
Copy link
Owner

mskocik commented Jun 5, 2024

I am open to this enhancement.

I am not sure your JSDoc types are correct, but I am not an expert in JSDOc 🤷 Have you tried it on the codebase itself?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants