-
Notifications
You must be signed in to change notification settings - Fork 37
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
Type defs #5
base: master
Are you sure you want to change the base?
Type defs #5
Conversation
doesn't seem like it will work any other way
Thanks @augustblack for the huge work! |
Alright, let me know. Happy to make adjustments if needed. I'm concerned that the way I have it set up requires a nightly build of typescript. Only the most recent typescript will recognize the "import": { "types" :... } format in package.json Maybe there is a better way to organize the definitions for less bleeding-edge implementations. This is my first time trying to package ts definitions. |
I agree, if a not-stable version of TS is needed I guess this can not be considered for merging now.
Me too :-) Need to gather some data before reviewing / enhancing. I'm converting the PR to "draft" since I suspect more work is definitely needed. |
No problem. Fwiw. the definitions work great and I don't suspect it will be long before TS 4.7 is released. AFACT, if we could pull the defs into a single .d.ts , then we shouldn't have issues with TS < 4.7 The problem is the subpath import structure you have with janode and trying to match that in the type defs. For example, you import for JS with:
Having the TS defs mimic the subpath audiobridge plugin import is the hard part. To do so, we need to afaict have the defs in a similar folder structure. However, only TS 4.7 can read package.json in such a way as I have in this pull request to define the subpath imports. Currently, this PR does it so:
If you like, I could clean it up into one .d.ts file and have import on the TS side do something like:
That would, however, cause conflicts I imagine when you are pulling the type definition for the AudioBridgePlugin from 'janode', but the actual code from 'jandoe/plugins/audiobridge' Maybe there is a way to do a single .d.ts file and still import from a subpath like janode/plugins/audiobridge, but I couldn't find it. The only way I could find to do the subpath import was the one proposed in this PR that requires the newest TS version. Thanks for the consideration and happy to follow any suggestions you have. |
I fixed a few minor things. I'm sure as I test this out, there will be more. To test, you will need to add to your project where using janode:
nightly isn't needed, beta is enough. Fwiw, the TS 4.7 should be released by the end of May. and then in tsconfig.json for your project, be sure to set:
No hurry on my part for the merge (if at all). From what I can tell, this PR has no intrusion on the JS side of things and should be safe to merge. |
Thx i was looking for this ! Works well with typescript ! |
That's great, @rchoffar I've only been using it on the audiobridge. Please let me know if there are any type issues with the other plugins. |
I tried to use it with videoroom plugin and it worked well on 0.x |
@rchoffar what is not compatible with 1.x ? janode does not still support multistream syntax, but it should work on janus 1.x using the 0.x syntax. If you discovered something that is not working please submit a new issue. |
@atoppi No sry that's not what i wanted to say, i wanted to upgrade to 1.x in order to use multistream features but janode does not support multistream syntax as you said. |
fwiw, typescript 4.7 has been out for a while now. making things work is now as simple as: |
Any news on this? |
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.
just got some time to check the status of this PR
@augustblack I've left initial comments and please also consider the following points:
- my current concern is that the intellisense in the Visual Studio Code IDE is not using those types declarations, that makes me think that something in the design/location of files is still not okay.
- We should update the defs after the recent releases of janode.
@@ -3,6 +3,8 @@ | |||
"description": "Meetecho adapter for the Janus WebRTC Server", | |||
"version": "1.6.2", | |||
"type": "module", | |||
"main": "src/janode.js", | |||
"types": "./types/janode.d", |
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.
is this a typo?
}, | ||
"files": [ | ||
"src/*.js", | ||
"src/utils/*.js", | ||
"src/plugins/*.js" | ||
"src/plugins/*.js", | ||
"types/**/*" |
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'd prefer specifying subfolders and file extension here (likewise the js)
@@ -0,0 +1,47 @@ | |||
import { ServerObjectConf } from './janode.js' |
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.
why are we importing js
files from d.ts
?
Hello, is there any update on this PR? |
I just noticed that my comments have never received response @augustblack |
I've been updating the ts defs for the audiobridge and streaming plugins incrementally as I am working on my project, but I don't think I'll have the capacity to maintain the type defs for all plugins as janode develops, or even keep things up to date. I personally think it would be less work and more appropriate to convert janode to TS. #24 Is there any desire to move in that direction? I wish I could help out more. |
@augustblack not planned migrating to TS in the short term unfortunately. |
Hi @atoppi, I recently watched the Janode conference (https://youtu.be/z8ptMqZ9bHk?t=1445) and found it really insightful – thank you for sharing the knowledge! Based on the regret you expressed in that video time stamp I have shared, I too believe migrating the Janode codebase to TypeScript, as suggested by @augustblack, could significantly benefit the community, providing good developer experience and better tooling support. I would be happy to spearhead this effort and contribute my time to this migration if the team at Meetecho is open to it, I’d like to propose setting aside some time to discuss the roadmap and plan. Any further thoughts on this would be appreciated. |
Hi @lagupa thanks for the feedback. When it comes to the main topic, I expressed regret about using JsDoc in place of TS for documentation since JsDoc IDE support is poor according to my experience. I will be more than happy to review and contribute to either a new PR or a revamp of this one (that is probably outdated by now). |
Here is a potential first start at typescript definitions for janode.
I did my best to create the defs without introducing any extra tooling.
All defs live under ./types. However, it does require modifying the package.json
I believe that since you require a minimum of node 14, this should be fine.
To use with typescript, one will need a recent 4.7 and set ["moduleResolution": "nodenext"] in the tsconfig.json
I'd be happy to do my best to maintain the types moving forward