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

Add Typescript type definitions to javascript frontend library #1413

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

hingobway
Copy link

Hi! I have been trying out the new WebView features in v8, and I noticed that the current frontend library is incompatible with Typescript.

I am submitting this PR to add a simple type declarations file to the existing project. Without type definitions, Typescript users either cannot use the library, or must disable type checking for this library, which means they also have no access to the JSDoc documentation you've written. This fix is similar to releasing @types types for javascript code, but as this library is not a published npm package I figure colocating the definitions may be the best solution, at least in the short term.

The only downside to this is that it creates an additional source of truth for function annotations (JS users see the original JSDoc comments, while Typescript users can only see them if they are in the .d.ts file.) The only better solution I know of is to fully migrate to Typescript, so for that reason it is very common to maintain types and JS code separately for libraries not originally written in typescript.

Most of the index.d.ts file was generated automatically by the typescript compiler, plus a handful of my corrections.

Let me know if I can improve anything or if I can help answer any questions about how these definitions work. I am already using them on one project and they have been working flawlessly so far.

Thanks!

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

Successfully merging this pull request may close these issues.

1 participant