-
-
Notifications
You must be signed in to change notification settings - Fork 593
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
refactor: Fix TypeScript error that namespace Parse
cannot be found
#2452
Conversation
Thanks for opening this pull request!
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## alpha #2452 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 64 64
Lines 6256 6256
Branches 1446 1476 +30
=========================================
Hits 6256 6256 ☔ View full report in Codecov by Sentry. |
What are we using |
it ensures that our autogenerated types matches @types/parse |
@mtrezza Is this good to merge? I updated the CI, now we can see how many tests failed. When it reaches 0 is when we can publish types. |
Could you help me understand why that is necessary? Aren't the generated types always correct, because they reflect the method and variable types as they are defined in code? |
But shouldn't our generated types always be correct? In your screenshot, if the type is any, then it's any, if it's void, then it's void. We define that type in code after all. Or what does the error in your screenshot tell us - that we have set the wrong type in code? |
I'm not a Typescript expert but I believe after this PR is merged you can publish the types if you want and incrementally add, which was always the original intention. The types test suite tells that the types in our code is wrong or missing types. We are doing this for the sake of completeness. I can foresee tons of users posting issues like #1368 |
Originally we didn't publish the types, because during the time of gradual conversion to TS the DT types were more complete had a greater benefit for developers. Had we published the types, they'd have been in conflict with DT and a developer would have had to remove the more complete TD types for our less complete own types. We also said that once we achieve a decent type coverage, specifically replace enough of these Now I understand that the types check here errors because we still have many of these
|
How do we check type overage? That's what the types test suite is for. It makes no sense to throw away years of work that went into @types/parse. It's more the just find
The hard part is done with this PR. I have another branch that fixed over 200 errors. I can get this done in a week.
Let's take Unfortunately we can't rename |
Right, how do we do that at all? We can't rely on DT types, because that may not be up to date. Our code is the source of truth.
I guess it exists in Parse Server then? So, Parse Server should provide these specific types, not this SDK, right? If it helps with the conversion to keep DT for now, let's keep it. But I think we should set a point in time to remove it. |
We use it as a base, we can always change and update the test suite to match the current state of the SDK.
Just mock them and throw an error if called client side. |
OK, but let's aim to remove the DT dependency at some point in the near future.
Can't Parse Server provide these types? If the types a specific to the Server environment, the client SDK shouldn't provide them at all IMO. |
We don't have a dependency on DT, we are just using the test suite thats all
I don't think it can. Let's fix the types first then worry about that when we get there. |
Parse
TS errorParse
cannot be found
Now that I think about it we can use eslint to run the tests without waiting for it to reach 0. But yes that's the plan. |
You mean we could replace dtslint with eslint immediately? Do you want to do that, or should I merge the PR as is? |
Let's merge this first |
Pull Request
Issue
Ideally we would like to be backwards compatible with @types/parse. @types/parse uses namespaces while this SDK uses modules. This PR fixes
Cannot find namespace "Parse"
error.Approach
parse/node
andparse/react-native
with teststest:types
script to include test error countTypes test errors left: 495 (from 585)
TODO: (Added to #2012 (comment))
Tasks