cesium icon indicating copy to clipboard operation
cesium copied to clipboard

Deprecated defaultValue.EMPTY_OBJECT and created EmptyObject standalone constant

Open anpaulan opened this issue 1 year ago • 5 comments

Description

  • Fixed missing JSDOC for EMPTY_OBJECT
  • Deprecated EMPTY_OBJECT property in defaultValue
  • Created standalone EmptyObject constant (via EmptyObject.js) per recommendation

Collaborated with @hotpocket

Issue number and link

Fixes Issue #11326

Testing plan

Tried to run this test in defaultValueSpec.js, but console.warn was not called: test did not run as expected.

it("Calls console.warn", function () {
    spyOn(console, 'warn');
    defaultValue.EMPTY_OBJECT
    expect(console.warn).toHaveBeenCalled();
  });

Author checklist

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

anpaulan avatar Oct 07 '24 01:10 anpaulan

Thank you for the pull request, @anpaulan!

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

github-actions[bot] avatar Oct 07 '24 01:10 github-actions[bot]

Thanks for the pr @anpaulan. However I don't think we want to make this change currently. I didn't remember there were 2 issues open related to this.

PR https://github.com/CesiumGS/cesium/pull/12207 for issue https://github.com/CesiumGS/cesium/issues/11674 is removing the defaultValue function and should be changing how we handle the EMPTY_OBJECT already. I don't think we want both of these changes. In that PR/issue we had settled on leaving it in the namespace of defaultValue. I believe removing the function should also inherently fix the typescript issue too but we can be sure to check that in that PR.

Maybe you could work with @dave-b-b to combine the changes?

CC @ggetz

jjspace avatar Oct 07 '24 15:10 jjspace

Good catch on the conflict here @jjspace.

To sum up the result of the discussion around #11674, it sounds like we'd want to:

  • Deprecate defaultValue (the function)
  • Keep defaultValue the namespace

Correct?

If that's the case, we should be able to do something like the following and still resolve the typescript error. If it becomes a namespace, defaultValue should be renamed DefaultValue.

/**
 * Utilities helpful for setting a default value for a parameter.
 *
 * @namespace DefaultValue
 */
const DefaultValue = {};

/**
 * A frozen empty object that can be used as the default value for options passed as
 * an object literal.
 * @type {object}
 * @memberof DefaultValue
 */
DefaultValue.EMPTY_OBJECT = Object.freeze({});

export default DefaultValue;

In that case, defaultValue and defaultValue.EMPTY_OBJECT will still need to be deprecated.

ggetz avatar Oct 09 '24 16:10 ggetz

Good catch on the conflict here @jjspace.

To sum up the result of the discussion around #11674, it sounds like we'd want to:

  • Deprecate defaultValue (the function)
  • Keep defaultValue the namespace

Correct?

If that's the case, we should be able to do something like the following and still resolve the typescript error. If it becomes a namespace, defaultValue should be renamed DefaultValue.

/**
 * Utilities helpful for setting a default value for a parameter.
 *
 * @namespace DefaultValue
 */
const DefaultValue = {};

/**
 * A frozen empty object that can be used as the default value for options passed as
 * an object literal.
 * @type {object}
 * @memberof DefaultValue
 */
DefaultValue.EMPTY_OBJECT = Object.freeze({});

export default DefaultValue;

In that case, defaultValue and defaultValue.EMPTY_OBJECT will still need to be deprecated.

Hi! Thank you for sending this over.

Good catch on the conflict here @jjspace.

To sum up the result of the discussion around #11674, it sounds like we'd want to:

  • Deprecate defaultValue (the function)
  • Keep defaultValue the namespace

Correct?

If that's the case, we should be able to do something like the following and still resolve the typescript error. If it becomes a namespace, defaultValue should be renamed DefaultValue.

/**
 * Utilities helpful for setting a default value for a parameter.
 *
 * @namespace DefaultValue
 */
const DefaultValue = {};

/**
 * A frozen empty object that can be used as the default value for options passed as
 * an object literal.
 * @type {object}
 * @memberof DefaultValue
 */
DefaultValue.EMPTY_OBJECT = Object.freeze({});

export default DefaultValue;

In that case, defaultValue and defaultValue.EMPTY_OBJECT will still need to be deprecated.

Thank you for the guidance! I was going through this PR as well as PR #12207 and I think you are right. I can go ahead and deprecate defaultValue and update the name space. But when I do so, I would need to work with @dave-b-b to figure out what would be used in place of defaultValue? My understanding is when I deprecate defaultValue, we should then redirect folks to the replacement function.

anpaulan avatar Oct 11 '24 17:10 anpaulan

My understanding is when I deprecate defaultValue, we should then redirect folks to the replacement function.

Yes, this correct.

I think it's be worth asking @dave-b-b what the current timeline on https://github.com/CesiumGS/cesium/pull/12207 is, and coordinate changes as needed. I'll add a message to that PR.

ggetz avatar Oct 14 '24 14:10 ggetz

Closing in favor of https://github.com/CesiumGS/cesium/pull/12507

jjspace avatar Mar 13 '25 19:03 jjspace