Has someone a skeleton for a Peertube plugin written in Typescript?
Is there a way to have Peertube’s declaration files? (for RegisterHook, PeertubeHelper, …)
Hey @JohnLivingston you might be interested in following this issue :
opened 07:52AM - 21 Jun 21 UTC
Component: PeerTube Plugin :package:
Type: Enhancement :sparkles:
<!--
Please read FAQ.md and docs.joinpeertube.org first.
Please search among p… ast open/closed issues for a similar one beforehand:
- https://github.com/Chocobozzz/PeerTube/issues?q=
All done? Then please fill the following mandatory form to help us triage your request.
-->
**Describe the problem to be solved**
In order to develop a __PeerTube__ plugin in Typescript, I should be able to import __PeerTube__ plugin API type definitions.
<!--
Provide a clear and concise description of what the problem is.
Ex. I have an issue when [...]
-->
**Describe the solution you would like:**
Writing a plugin could look like the following :
```ts
import { RegisterServerOptions } from '@peertube/plugin';
export async function register({ registerSetting }: RegisterServerOptions) {
registerSetting({
// ...
});
}
export async function unregister() {
return;
}
```
Publishing to [https://github.com/DefinitelyTyped/DefinitelyTyped](DefinitelyTyped) is another option:
```ts
import { RegisterServerOptions } from '@types/peertube';
```
Or maybe:
```ts
import { RegisterServerOptions } from '@types/peertube-plugin';
```
I don't know if it makes much sense to publish either part of `client` or `server` as a npm package.
But if it does I would consider publishing plugin typedef with these.
For ex:
- `@peertube/client`
- `@peertube/server`
> Just so you know there is an npm package named `peertube` with no connection with this project:
> https://www.npmjs.com/package/peertube
**Describe alternatives you have considered**
If it doesn't make sense the alternatives would be to either create another `package.json` in `./server/types/plugins` for example.
Or maybe create a dedicated directory in this repository and publish it to https://github.com/DefinitelyTyped/DefinitelyTyped#create-a-new-package
As for the best name of such package, I'd love to hear other opinions, because I'm still unsure as to weather it would make sense to expose typedef other than the plugin ones.
<!-- Remove if you have not considered alternatives.
Let us know about other solutions you have tried or researched.
-->
1 Like
Oh, I forgot to mention here that I have made some progress on that question!
I will answer on the issue tracker.
I have answered on the tracker.
I can give you the procedure I used to modify the quickstart plugin to enable typescript. I have it in a mail (its in french).
I can’t find the procedure.
You can check commits that I made on this branch Commits · JohnXLivingston/peertube-plugin-livechat · GitHub on April 7th 2021.
I made separate commits for every task:
At the end, there was some little mistakes that I fixed later on another branch. But you should be able to use this work if needed