-
-
Notifications
You must be signed in to change notification settings - Fork 595
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 #2044
base: alpha
Are you sure you want to change the base?
Typescript #2044
Conversation
Fixes parse-community#1660 (Caused by passing a Parse.File into the LocalDataStore, which is unexpected)
…ic localDataStore)
Thanks for opening this pull request! |
package.json
Outdated
@@ -55,6 +55,7 @@ | |||
"@semantic-release/github": "8.0.7", | |||
"@semantic-release/npm": "9.0.2", | |||
"@semantic-release/release-notes-generator": "10.0.3", | |||
"@types/facebook-js-sdk": "^3.3.9", |
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.
What's the purpose of this dep?
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.
There's the file FacebookUtils.ts
where the FB
global is used.
You mean circular dependencies? |
@parse-community/js-sdk Any help to review this is appreciated. |
Yes, you'll find that currently the failing tests involve classes that extend ParseObject that failed to initialize with the error |
I'm not sure if this is the right move, but is it possible for us to move off the |
We've added madge to the Parse Server CI, I wasn't aware we don't even have that in the JS SDK. Would you mind opening an issue + PR and add madge like it's added in Parse Server (see |
Sure, will open a PR for that. |
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.
@swittk Thank you for picking this up! I added a few comments and nits
For the issue you are having with the unit tests try adding the following to the 3 test files that are failing. I hope this helps.
jest.dontMock('../ParseObject');
src/RESTController.ts
Outdated
@@ -332,3 +348,4 @@ const RESTController = { | |||
}; | |||
|
|||
module.exports = RESTController; | |||
export default RESTController; |
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.
This red symbol means you are missing a new line at the end of the file
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.
Fixed
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.
There are a lot of new lines missing and potential other lint issues. We should switch from eslint to tsc (npm run build:types
) in a separate PR.
src/ParseSchema.ts
Outdated
} | ||
if (type === 'Relation') { | ||
// TODO: Why does options exist here? | ||
return this.addRelation(name, options.targetClass, options); |
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.
options
here can be removed as it is unused
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.
Thank you for the clarification 👍
src/ParseQuery.ts
Outdated
return this; | ||
} | ||
// TODO: Typescript.. How does this work? Does this even make sense? | ||
return (this._xhrRequest.onchange = () => this.cancel()); |
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.
This should be written as the following as it should return a ParseQuery. cancel
is supposed to be chained like the other functions.
this._xhrRequest.onchange = () => this.cancel();
return 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.
Ahh OK. Thank you.
Thanks. That fixed two of the tests. (Sorry; I'm not that used to working with Jest.) |
I just checked your last commit you are still missing For |
Jest tests appear to be fixed. |
@swittk I saw your
An alternative would be revert those files with circular dependencies back to JS and we can tackle these issue in a separate PR so we can get this PR merged. (~44/62) files is impressive. @mtrezza Thoughts? |
Just asking.. I'm trying the refactors, but I'm encountering errors in the tests, since they expect to mock ParseObject (e.g. (I'm starting to get the sense that the very separated, single function/class definition in each file might've originally been due to reasons related to testing) |
@swittk You would have to something like this but for it to work you would need to get rid of the dependency cycles first like the previous unit test issue. If you give me access to your fork. I can clean this PR up for you.
|
Thanks. I've added you as a collaborator to my fork. |
This comment was marked as spam.
This comment was marked as spam.
Would using registration of currently heavily reused classes (ParseQuery, ParseACL) into Since most of the |
@dplewis I've made another branch with my proposed changes by using CoreManager as a central registry for classes that are reused. Most of the circular dependencies are fixed (and the rest are easily solvable using similar methodology), and it's enough that the tests and integrations now all pass. Edit : I've since refactored more on the mentioned branch and only 1 circular dependency remains which is |
@mtrezza I would keep it open. If anybody wants to help with typescript support everything they need is in this PR. It would be hard to find if it was closed. I’m too lazy to bookmark it lol. @swittk put hours into this it’s only right that we close it when we have full TS support on version 6 of the SDK |
Pull Request
Issue
Closes: #2012
Approach
.ts
, along with correcting some types that appear to have been out of date.ParseObject
; help appreciated.export default
, so tests have been edited to reflect the behaviour,const module = require(...).default
is nowconst module = require(...)
.Tasks
ParseObject