-
Notifications
You must be signed in to change notification settings - Fork 77
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 definitions #166
Conversation
…compiler for type definitions As part of adding Typescript, a number of dependencies had to be updated. All @babel packages and @rollup packages were updated. Additionally prettier-eslint-cli had to be updated due to a typing issue in the dependency tree. This also meant that eslint also had to be updated to maintain compatibility. Due to these package changes the minumum node devEngines version has been bumped to 16. A tsconfig.json file has been added, as well as renaming the base index file from index.js to index.ts. Adds packages to enable WaniKani#141
…e definition output constants.js has been changed to a typescript file to enable the exporting of the DefaultOptions type. This is then used by various function definitions, which provides type checking for the parameters. Regexp has been changed to RegExp as Regexp was resolving to the any type. Other parameters defined as Object have been specified with types to match their expected input. TOKEN_TYPES's export was removed as it was unused and was being generated into the d.ts file. Resolve external typings for WaniKani#141
This is a great addition, thanks for contributing! |
Sorry for the delay, I've taken a quick look and the docs site no longer compiles due to invalid syntax. You can try running Would you mind taking a look at this? |
Sure thing. I'll take a look at it this weekend. |
…les and typings Added better-docs to piggyback off of its typescript plugin. Updated instances of string to String and boolean to Boolean. This matches the rest of the existing documentation. Typescript types are unaffected by these changes and automatically get converted to the correct typescript type. Changed instances of [index: string]: string to Object.<string, string> JSDoc type. This gets converted in typescript, but the previous syntax was not supported in JSDocs. WaniKani#141
Hey sorry for the delay. Things have been pretty hectic on my end. I've updated the doc generation to handle typescript files, and changed any conflicting types. Generated typescript types are not affected by this change. I've also changed some casing of typings back, such as |
No problem, busy here as well, but I'll do my best to take another look at it this week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some minor changes, but otherwise this is looking good now 👍
I'll publish on the weekend for you.
This PR implements Typescript compilation as discussed in #141. However, I have taken the approach to incrementally enhance the UX for this, rather than do a wholesale refactor of the project, or move to a different build system as discussed in the comments.
A number of packages did have to be updated in order to enable this, but there is no change to any actual code. More information about what packages have been updated and why can be found on the first commit message. The tsconfig option
allowJs
has been used to generate types from the javascript files, rather than convereting all files, and associated code to Typescript. This allows for package consumers to use the type definitions from the package, published through thetypes
property that was added into therelease.js
script.This all results in the following defintion file being generated
I'm not sure how you would like to proceed with testing this, and would be open to any guidance or experience anyone has in this area.