-
-
Notifications
You must be signed in to change notification settings - Fork 616
Improving Matrix for Developers #1546
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
Comments
Awesome idea, I'm getting headache after struggling with /* eslint-disable @typescript-eslint/ban-ts-comment */
import _matrix from 'matrix-js-sdk';
// @ts-ignore
import { EventStatus, LoginPayload, MatrixEvent } from '@types/matrix-js-sdk';
// @ts-ignore
const matrix: typeof import('@types/matrix-js-sdk') = _matrix; |
It's a good idea, but to be honest I'm not sure if I want to finish it due to me taking a long break from this platform. I've already done a substantial amount of the work, which will be uploaded shortly. |
Just a quick update on where I'm at: I'm not really sure how any of the Matrix developers feel about this, as they haven't left one comment or reaction in over a week. I'm therefore halting my contributions forthwith, as I don't wish to spend any more hours working on something that might get closed when someone looks at it. I will definitely upload the substantial amount of work I've already done to the relevant repository. @gbaranski perhaps you could continue the work? I won't blame you if you say no. |
@resynth1943 that might be great opportunity to learn how this works. Can any of the matrix-js-sdk developers share their opinion about it? |
Hi @gbaranski, I've updated the code here. Just to be clear, I don't wish to offend the Matrix developers, but quite frankly I'm not sure whether I should be spending more time on this; as I've seen no response, I'm honestly not sure if the developers are skeptical about this, or if there's a general consensus that this is a good proposal. I don't want to dedicate hours of my time to something that could end up being refuted; in that respect, I could be working on my new framework to automate the operation of my computer, and that seems like a wise idea in the middle of a global pandemic (especially since no public body seems to know what they're doing). Anyway, for anyone who wishes to take over, here are some notes about my refactored code:
Thanks again, |
We're already using TypeScript in various places, so continuing that conversion seems like a good idea. I would recommend small PRs for anyone interesting in converting bits at a time. There are lots of interesting ideas here, but it's hard to work with as single massive issue, because each part would complete at different times, so they should be in separate issues. Instead of a massive issue like this, it might be more practical to discuss with the team and work on a small piece instead. |
@jryans thank you for your response. I wasn't sure whether you actually wanted to go forward with this, because After discussing it with a team member, they recommended I won't be working on this, but I've outlined what needs Best of luck! |
Improving Matrix for Developers
TL;DR, for the lazy π€:
I think we can all say that TypeScript makes for a substantially improved developer experience. Ranging from auto-suggested methods, properties and functions, the use of TypeScript makes a library so much easier to use: in most cases, understanding the library isn't actually needed. Auto-suggestions can empower developers to learn a library on-the-go, without requiring the use of complex documentation websites.
TypeScript is the way forward, and the developer community have continuously established this fact: major libraries have quickly gained support for TypeScript. Developers favour TypeScript because it has, in many respects, greatly simplified the use and deployment of JavaScript. π
Where We're At
Without Element, Matrix may not be where it is today. In this respect, introducing TypeScript would substantially reduce the burden on developers who rely on the JavaScript SDK, including the developers of Element.
I speak from experience when I say that Matrix JavaScript SDK has definitely not been easy to use. Many a time I've had to resort to asking questions in the Developer room, placing more burden on overworked developers in the midst of a pandemic.
I'd like to spend time improving upon that, which will ultimately benefit everyone.
This will allow developers to use our SDK without reading ghastly, non-user-friendly, web-pages of documentation. Instead of this outdated approach, we can read documentation without leaving the editor, saving hours of understanding the internals of our SDK.
We can do better! π
It's Time to Improve
That's why, with your support, I'd like to finally bring TypeScript into our SDK. Instead of relying on other developers to maintain types, we can just do it ourselves! π
Behind the scenes, I've spent hours working on native types for our SDK. This will make life easier for everyone: consumers of the SDK, maintainers of the external types, the Element developers, and newcomers who wish to extend Element. π―
What Do You Think?
I'd love to hear what you think. If TypeScript isn't a good fit, that's OK, but it's a proposal we definitely need to consider. I've already outlined the numerous benefits of using TypeScript above. I think it's a good fit for this library, but I welcome feedback that suggests the contrary!
My thoughts on the matter: we already use TypeScript quite heavily in our React SDK, and it may be good to unify that with the JS SDK. TypeScript just makes things... easier.
I Need Your Help
However, I've encountered a few problems (and questions β), which are enumerated below:
"Can I convert
MatrixBaseApis
from a mixin into a class?"As TypeScript doesn't really support mixins without substantial type hackery, it may be wise to convert this to a class. In that vein, we would have to extend
MatrixBaseApis
with theEventEmitter
interface.utils.inherit
isn't type-safe, and IMO, is a workaround for forcing multi-inheritance in a language which doesn't natively support it. Even the Node developers discourage use ofutil.inherits
. πWe'll need to rethink our API Reference website.
Right now, we use JSDoc for documentation, which doesn't support TypeScript. There are alternatives such as TypeDoc, but I haven't had a good experience using that, so I'd recommend against it. π
If we do move to TypeScript, we'll need a generator which supports it. We could either continue to maintain both an API Reference and TypeScript typings, or adopt React's style of documentation, which includes easy-to-understand guides for using their library.
This may be a good time to rethink our documentation. In the past, I have proposed a set of guides for using this SDK, which I would be open to writing myself. The style of React's documentation is very easy to comprehend, with a clear navigational structure, unlike a classical API Reference (which is an approach many libraries now avoid altogether).
Should we also include Flow typings?
I'm slightly against it π, but figure I may as well ask: **would it be worth using a TypeScript β Flow generator, to cater to Flow users?
Do we care about Flow users? π
If we do end up transitioning to TypeScript, it's important to note whether or note the core Matrix developers actually know how to use it. I wouldn't want to exclude anyone from developing the SDK π , despite the major benefits of TypeScript.
How are we going to set up the CI?
TypeScript is really useful when used in a CI, so we can automatically check whether or not PR's are wrongly typed (or contain errors). In theory, this should be relatively easy to setup: our very own Matrix React SDK contains a CI for checking TypeScript, so it should be a matter of transferring the configuration over to the JS SDK. π
Publishing TypeScript
Same as above, we've already set this up, but seems like a good point to note. We'll definitely need a script to do this... π€
(This list may be updated in the future.)
The text was updated successfully, but these errors were encountered: