Skip to content
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

Replace defaultValue with ?? #12207

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

dave-b-b
Copy link

@dave-b-b dave-b-b commented Sep 20, 2024

Description

This is a partial pull request to verify that I am making the right kinds of changes.

Issue number and link

This is a partial fix. I don't want to link here and have this automatically close the ticket. But the ticket is #11674.

Testing plan

I ran npm run test. It failed some of the tests, but none of the tests related to the changes that I made. (It seemed like they were all timeout issues)

Author checklist

  • I have submitted a Contributor License Agreement
  • I have added my name to CONTRIBUTORS.md
  • I have updated CHANGES.md with a short summary of my change
  • I have added or updated unit tests to ensure consistent code coverage
  • I have updated the inline documentation, and included code examples where relevant
  • I have performed a self-review of my code

This is a partial commit to check whether I am making the correct changes
- accidentally changed createDefaultTerrainProviderViewModels() to createDefaultTerrainProviderViewModels
Copy link

Thank you for the pull request, @dave-b-b!

✅ We can confirm we have a CLA on file for you.

@jjspace
Copy link
Contributor

jjspace commented Sep 20, 2024

This is a partial fix. I don't want to link here and have this automatically close the ticket. But the ticket is 11674.

Just FYI, as long as you don't specifically use the exact keywords that Github set up it won't automatically link a PR to an Issue.

@@ -303,7 +302,7 @@ Object.defineProperties(BillboardGraphics.prototype, {
* @type {Property|undefined}
*/
pixelOffsetScaleByDistance: createPropertyDescriptor(
"pixelOffsetScaleByDistance"
"pixelOffsetScaleByDistance",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like you have the wrong version of prettier installed or your editor configuration is wrong. These changes are distracting from the intended change of this PR (I'm working on the update in #12206). Can you do a npm install and make sure to run npm run prettier? Also probably worth checking that the pre-commit hook is working as intended so these can't even be committed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. I see the pre-commit hook. There was probably something I did wrong. But it looks like it is preventing commits now.

I ran prettier and merged the changes into my pull request.

image

Copy link
Contributor

@jjspace jjspace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dave-b-b, looks like you're on the right track! I think all the existing replacements look good (other than the comment below). Do you want to continue with the rest in this PR and we can merge them all at once?

@@ -2265,7 +2256,7 @@ function updateZoomTarget(viewer) {

const scene = viewer.scene;
const camera = scene.camera;
const zoomOptions = defaultValue(viewer._zoomOptions, {});
const zoomOptions = viewer._zoomOptions ?? defaultValue.EMPTY_OBJECT;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defaultValue.EMPTY_OBJECT is frozen and cannot be modified. Most of the places we use it are only reading information from the object so this is not a problem. However some places we used defaultValue we do modify the properties later (like this one). There's probably discussion to be had about whether these objects should be modified for later but for the sake of keeping this PR isolated let's just preserve the existing behavior.
Basically don't replace calls like these with the EMPTY_OBJECT, just keep the {}. I think this is what's causing your test failures.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jjspace I'll keep working on this so we can merge everything at once. Thanks for working with me! And sorry for the late response.

@jjspace jjspace changed the title Issue#11674 Replace defaultValue with ?? Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants