-
-
Notifications
You must be signed in to change notification settings - Fork 589
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] Typing Support #983
Comments
any progress on TypeScript declaration file? I try to use TypeScript 3.7 new feature I failed with tons of The reason of failure of generating the typing is the matrix code base
|
This new feature from TS 3.7 is really cool. I'd like to suggest that you try to use my declaration file which is written by me handly from scratch at here: https://github.com/huan/matrix-appservice-wechaty/tree/master/src/typings And if you think it is useable, I'd like to publish it to the |
I have tried your declaration file before, but it might be missing some functions(like |
Yes, It would be great if we can get the declaration from the source code automatically. I hope you can figure it out, looking forward to the better version of the declaration files! 👍 |
It need do have some codemods on the current code base like transform all commonjs style import/exports to ESModule, and transform all ES5 class to ES6 class. |
And there are lots of JSDoc style type refer like |
The TypeScript update is that our tests are a disaster and don't work with typescript. We're transitioning to TypeScript proper rather than supplying declarations. |
The Babel supports typescript doesn't means it will be typed by TS. I'm going to working on the .d.ts generation from the current codebase and release it as a separate package until the official codebase can provide a high quality typescript definition Problems when generating dts
|
@Jack-Works there's a plan to rewrite/port to typescript, and a stage 1 PR is not a final representation of all the work required. I would recommend holding off until we fix our tests so we can get TypeScript properly landed, which will have a stage 2 PR for typings of the stuff we don't port (assuming it doesn't break everything). |
Here is my auto generated type definitions. I will improve the generated files these days. |
Ok. https://github.com/Jack-Works/matrix-js-sdk-type Finally my work ends. But the type is very, very incomplete and I have no patience to continue working on the typescript declaration generation. Wish matrix to offer their own declaration some day! |
Just sent the PR for typing for Matrix JS SDK (matrix-js-sdk) to DefinitelyTyped. |
The PR is merged to the DefinitelyTyped repository. now we can use npm install @types/matrix-js-sdk -D There are lots of parts will need to be improved, so please not be too surprised when you ran into any type of mismatch problems with this typing. |
@huan I can't get it to work with |
@andrevmatos Hi, I installed it and found that it only has an So I think maybe you can send a PR to matrix-js-sdk and to see if the author will accept removing the typing from it? However, that will break some existing projects, which will require them to install the Another way to work around this, I think if I was you, I'd like to... run a |
@huan I managed to get around the issue by adding |
Note: I change my idea and I'm going to continue to maintain the generated type definition Please check out https://github.com/Jack-Works/matrix-js-sdk-type |
Since we have a @types/matrix-js-sdk, can Matrix team either remove the typing inside the SDK, OR combine the typings from @types into the SDK? |
Neither will happen, the long-term goal is to move the entire SDK over to TypeScript. Current blocker: #1229 |
@t3chguy understood! Thanks. |
@t3chguy is this completed in V8? I checked release notes but haven't found anything related to typing. Thanks. |
No otherwise this issue would be closed + you can see most of the files are still It is blocked on #1229 |
@andrevmatos is this still working for you? I am getting the following error:
Note that I am using this within Angular, although that shouldn't cause the issue. I have also tried adding A workaround to use the DefinitelyTyped types for now would be really helpful |
@bergben our current workaround is to remove this package's borked definitions at prepare time so TS will pick up DefinitelyTyped's |
in case |
@andrevmatos @Jack-Works thank you both for the quick answer. I'll go with @andrevmatos workaround for now - I prefer using a source from DefinitelyTyped if available, but thanks anyway @Jack-Works! |
Another option that worked for me with the
|
Any progress with this? #1229 has been closed for unrelated reasons. Could anyone start Just Converting this library into typescript? #1546 (comment) seems to suggest this is definitely possible. |
We're already most of the way through a typescript conversion - if there are gaps, please open PRs. |
Ah apologies, i had a very old version of js-sdk cloned locally, i forgot to update my comment. There are some issues remaining wrt TS conversion, but yes, the majority has been done. |
I had spent around two full days to study the document and write the typings for
matrix-js-sdk
.With the typing system, it helped me a lot to learn the API and prevent lots of potential bugs. I think it's worth to publish them, the best will be integrated into our npm module.
The typing definition is still working in progress and heavy developing, you can watch it at https://github.com/huan/matrix-appservice-wechaty/blob/master/src/typings/matrix-js-sdk.d.ts.
I'll create a pull request to add the typing to this repository after I get my project done, and any suggestion will be welcome by leaving comments under this issue.
Link to wechaty/matrix-appservice#13
@Half-Shot
Thanks!
The text was updated successfully, but these errors were encountered: