jsforce icon indicating copy to clipboard operation
jsforce copied to clipboard

Discussion: Thoughts on converting library to Typescript

Open watzon opened this issue 9 years ago • 10 comments

Hoping to start a dialog about taking this library and converting it to use Typescript instead of plain javascript. It would most likely shrink the codebase (since you'd have access to all the wonderful syntactic sugar that es6 provides,), it would make the library more maintainable, and having the power of types would allow us to catch a lot of potential errors before they happen.

I would be 100% willing to get the ball rolling by creating a Typescript branch and starting the conversion process, but I'd like to know how the rest of the community feels about it.

watzon avatar Sep 01 '16 19:09 watzon

+1 for this

Suggestion: First step might be updating to es6 using lebab

loganvolkers avatar Sep 02 '16 22:09 loganvolkers

See also: https://github.com/jsforce/jsforce/issues/287

loganvolkers avatar Sep 03 '16 04:09 loganvolkers

@loganvolkers good idea with lebab. I've never used that before. Still has a ways to go, but it's proving helpful

watzon avatar Sep 03 '16 21:09 watzon

Comment as a code base author. I also sometime feel like to modernize the source code of JSforce which still remains as ES5 pure JS code, so the proposal is understandable. On the other hand, I'm afraid that possible contributers might not be in the edge and be lost when moved to different arch quickly. Additionally It is also to be considered the existing code has some parts of dynamic programming so moving to statically typed one will not be such straight-forward task. Finally, I personally use ES6+ (and sometime FlowType) in my other projects, not TypeScript, so if the modernization is required I might consider adopting ES6 first, which I think it might have broader cognition nowadays.

stomita avatar Sep 03 '16 22:09 stomita

+1 Typescript

bruceyue avatar Sep 18 '16 03:09 bruceyue

If anyone is interested I created definitions for the subset of the API that I needed to use. I don't have time to finish this right now but it could be used as the basis for a more complete implementation:

https://gist.github.com/cjdell/35c69fea2125cacfd5172f4e23de7b0e

cjdell avatar Dec 09 '16 12:12 cjdell

@stomita after some time to think about it I think I agree with your sentiment on not using Typescript in particular. Maybe if we were to start transitioning to ES6/ES7 syntax instead, and then add definition files for Typescript as we go? I agree that some people may not be comfortable yet with the syntax, but this is a good learning opportunity and I feel like it's mostly necessary since JavaScript is evolving

watzon avatar Dec 09 '16 16:12 watzon

-1 typescript.

tnoonan-salesforce avatar Dec 29 '16 23:12 tnoonan-salesforce

Just found this library: https://github.com/Kegsay/flow-jsdoc

It converts JsDoc types into Flow type annotations.

I haven't tried it yet, but it sounds like it could help remove the legwork of the switch.

loganvolkers avatar Jan 04 '17 01:01 loganvolkers

+1 to transition to ES6

cwheikki avatar Jan 07 '17 01:01 cwheikki

This should be fixed in v3, see: https://github.com/jsforce/jsforce/discussions/1529

cristiand391 avatar Jul 15 '24 19:07 cristiand391