-
Notifications
You must be signed in to change notification settings - Fork 302
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: migrate Coordinates and Ellipsoid to typescript #2437
base: master
Are you sure you want to change the base?
Conversation
8406a04
to
98fe688
Compare
98fe688
to
bdcd88a
Compare
bdcd88a
to
84a58e9
Compare
84a58e9
to
78161ca
Compare
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.
Thanks for the MR, well done :D
Should we not specified the return type of the different function of these new TS files ?
For example, for the function cartesianToCartographic of Ellipsoid
In the JS doc, we were specifying the return type, it was helping while reading the code.
I get that TypeScript is capable of inferring the return type but could be nice to still write it, like you did in Coordinates.ts. WDYT ?
src/Core/Geographic/Coordinates.ts
Outdated
this._normal = new THREE.Vector3(); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
if ((v0 as any).length > 0) { // deepscan-disable-line |
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.
if ((v0 as any).length > 0) { // deepscan-disable-line | |
if ((x as any).length > 0) { // deepscan-disable-line |
?
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.
I would like to remove the instanciation of Coordinates
with an array or a vector3 for typescript users but not break the API for javascript users until a major version bump. However, it seems the deepscan static checker can infer that x
(even if cast as any
) has no property length
and the CI failed. This is will be removed with the next major version bump.
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.
I don't understand why we do the condition on v0
though ? It's not given by the user , isn't ?
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.
Holy crap, I shall read more carefully, this is a suggested change, thought it was my code. xD
I indeed intended to check the value of x
, will fix it!
78161ca
to
826f483
Compare
@AnthonyGlt Return types in |
826f483
to
cf1fe3c
Compare
d4960ea
to
7a56b5f
Compare
7a56b5f
to
333cf72
Compare
@AnthonyGlt All good! |
Description
This PR includes:
Coordinates
from javascript to typescriptEllipsoid
from javascript to typescriptProposed breaking type changes:
Three.Vector3
, I propose that the constructor ofCoordinates
only accepts numbers as parameters. We could set from array, coordinates-like objects from corresponding methodssetFromArray()
orsetFromVector3
. Note that for js users, we would not for now break compatibility (maybe add a depreciation notice).Motivation and Context
As described in proposal #2396, we aim to gradually migrate our entire codebase (with the exception of deprecated modules) from javascript to typescript. We choose to start with modules with no-dependency and move up in the dependency tree.
This PR is the second step of Migrate geographic modules, migrating the both co-dependent modules
Coordinates
andEllipsoid
. This PR is a follow-up of #2436.