-
Notifications
You must be signed in to change notification settings - Fork 297
Add typescript types #343
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
base: master
Are you sure you want to change the base?
Add typescript types #343
Conversation
Because: - The JSDocs comments take up a lot of space, pushing down the actual implementation code - The JSDoc comments are more limited compared to declaration files (e.g. no imports) - Stremio web also uses `.d.ts` files so the team is already familiar with it
| serveHTTP: require('./serveHTTP'), | ||
| getRouter: require('./getRouter'), | ||
| publishToCentral: require('./publishToCentral'), | ||
| landingTemplate: require('./landingTemplate'), |
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.
FYI: The EN+ addon, and likely others as well, rely on this function. In the past, I worked around this by importing it directly from stremio-addon-sdk/src/landingTemplate, but that approach no longer works with TypeScript due to type restrictions. This seems like a good opportunity to properly export the function so that users can import it directly from stremio-addon-sdk, regardless of whether they’re using plain JavaScript or TypeScript.
|
Build is failing because of this: This seems like a bug/issue unrelated to this PR? |
Closes #291.
Initially, I went with the approach suggested by the linked issue; i.e. to transpile JSDoc comments to typescript declaration files (
.d.ts). But then I realized that wasn't the best approach because:Thus, I decided to declare the declaration files directly. Another plus is this doesn't require a build step nor the
typescriptdevDependency.I also updated the types to match the latest SDK version, as they were a little outdated.
I tested the changes locally with yalc and my own addons, most importantly Easynews+ which up until now used to rely on some typescript hacks to work well with the sdk. Besides my own human eyes I also leveraged AI (gh copilot + claude sonnet 4) to validate my changes against the documentation and everything appears to check out.
This PR makes the community @types/stremio-addon-sdk package obsolete going forward.
Next steps: