Parse-SDK-JS icon indicating copy to clipboard operation
Parse-SDK-JS copied to clipboard

Expand TypeScript support

Open mtrezza opened this issue 2 years ago • 18 comments

New Feature / Enhancement Checklist

Current Limitation

TypeScript support has been added with https://github.com/parse-community/Parse-SDK-JS/issues/1950. The next step is to expand it to more files.

Feature / Enhancement Description

Contributing

  • Change file extension to .ts
  • Remove @flow from file if it exists
  • Add file to ./tsconfig.json
  • npm run build:types
  • Fix types
  • Add / enable tests in types/test.ts
  • npm run test:types
  • Compare types to @types/parse

Progress (1/62)

  • [x] Analytics.js
  • [x] AnonymousUtils.js
  • [x] Cloud.js
  • [x] CloudCode.js
  • [x] CoreManager.js
  • [x] CryptoController.js
  • [x] EventEmitter.js
  • [x] EventuallyQueue.js
  • [x] FacebookUtils.js
  • [x] IndexedDBStorageController.js
  • [x] InstallationController.js
  • [x] LiveQueryClient.js
  • [x] LiveQuerySubscription.js
  • [x] LocalDatastore.js
  • [x] LocalDatastoreController.js
  • [x] LocalDatastoreController.react-native.js
  • [x] LocalDatastoreUtils.js
  • [x] ObjectStateMutations.js
  • [x] OfflineQuery.js
  • [x] Parse.js
  • [x] ParseACL.js
  • [x] ParseCLP.js
  • [x] ParseConfig.js
  • [x] ParseError.js
  • [x] ParseFile.js
  • [x] ParseGeoPoint.js
  • [x] ParseHooks.js
  • [x] ParseInstallation.js
  • [x] ParseLiveQuery.js
  • [x] ParseObject.js
  • [x] ParseOp.js
  • [x] ParsePolygon.js
  • [x] ParseQuery.js
  • [x] ParseRelation.js
  • [x] ParseRole.js
  • [x] ParseSchema.js
  • [x] ParseSession.ts
  • [x] ParseUser.js
  • [x] Push.js
  • [x] RESTController.js
  • [x] SingleInstanceStateController.js
  • [x] Socket.weapp.js
  • [x] Storage.js
  • [x] StorageController.browser.js
  • [x] StorageController.default.js
  • [x] StorageController.react-native.js
  • [x] StorageController.weapp.js
  • [x] TaskQueue.js
  • [x] UniqueInstanceStateController.js
  • [x] Xhr.weapp.js
  • [x] arrayContainsObject.js
  • [x] canBeSerialized.js
  • [x] decode.js
  • [x] encode.js
  • [x] equals.js
  • [x] escape.js
  • [x] isRevocableSession.js
  • [x] parseDate.js
  • [x] promiseUtils.js
  • [x] unique.js
  • [x] unsavedChildren.js
  • [x] uuid.js
  • [x] WebSocketController

mtrezza avatar Sep 01 '23 00:09 mtrezza

Thanks for opening this issue!

  • 🎉 We are excited about your ideas for improvement!

@mtrezza just realized I can’t edit the OP (original post). I would like to put my name down to claim some files in case @danielbm @sadortun or other developers want to work on them to prevent conflicts

dplewis avatar Sep 05 '23 01:09 dplewis

I'd say just post a comment with the sub-list you're working on and I'll update the main list from time to time.

mtrezza avatar Sep 05 '23 01:09 mtrezza

Alright, once the PRs are merged, I'll go ahead and cross the items off the list. Other than that, as always, a contributor is encouraged to read the thread to know whether someone is already working an the issue - or parts of it.

I also suggest to open a PR early while work is in progress, which allows others to have insight into the progress. To prevent blocking issues, as long as there is no PR (or the PR is stale) we would always welcome and suggest to others to start working on it if they asked.

mtrezza avatar Sep 05 '23 10:09 mtrezza

quick question, is this npm package setup to allow using the typescript definitions defined in the parse.ts file? I'd like to remove @types/parse as it's outdated, but removing it causes typescript compile issues now.

Could not find a declaration file for module 'parse/node'. '.../node_modules/parse/node.js' implicitly has an 'any' type.

Try npm i --save-dev @types/parse if it exists or add a new declaration (.d.ts) file containing declare module 'parse/node';ts(7016)

Thanks for your help.

tomgrowflow avatar Sep 11 '23 14:09 tomgrowflow

Hello I am not really sure this is entirely related but I open sourced my solution for providing types for custom database classes. What do you think about the approach? https://www.npmjs.com/package/parse-sdk-ts

theolundqvist avatar Oct 12 '23 19:10 theolundqvist

@theolundqvist Your comment seems more related to https://github.com/parse-community/Parse-SDK-JS/issues/1313. You may want to move it to there, if it is of use to the discussion there. If you are just asking for feedback about your project however, as it seems from your comment, you would do that in the community forum - GitHub issues are not the right place for that.

mtrezza avatar Oct 12 '23 20:10 mtrezza

@mtrezza I've been trying to tackle this here https://github.com/swittk/Parse-SDK-JS/tree/typescript What do you think? If this seems OK I plan to finish more of it soon.

There are a few places where I'm not sure though,

  • ParseGeoPoint static current() is supposed to return current GeoPoint, but it seems like the return result is wrapped in a callback
  • ParseObject has a couple of places where this.constructor is used, and Typescript doesn't really like this pattern, so I had to cast any at those places.
  • CoreManager.ts has a bunch of managers which appear to have either been defined with vague return values or incorrect function names, I've since corrected a few of them, but it's still not finished. Will look at the tests and DefaultManager implementation of each one to implement the correct types.

swittk avatar Oct 29 '23 10:10 swittk

@swittk could you please open a PR for review?

mtrezza avatar Oct 29 '23 21:10 mtrezza