Repository navigation
Implement RFC #334: Deprecate @ember/utils and the empty, notEmpty, none macros - #21632
NullVoxPopuli merged 4 commits into
Conversation
Implements RFC 334 and finishes emberjs#20968. One deprecation id, `deprecate-ember-utils`, covers all ten APIs: - `compare`, `isBlank`, `isEmpty`, `isEqual`, `isNone`, `isPresent` and `typeOf` from `@ember/utils` - `empty`, `notEmpty` and `none` from `@ember/object/computed` The deprecation is available in 7.5.0 and has `until: 8.0.0`. It is not enabled yet, because the RFC is not at Ready for Release (emberjs/rfcs#1056). `@ember/utils/index.ts` now holds the public functions, their API docs and the deprecation. The `lib/` modules stay as plain implementations. Ember's own code already imports them from `lib/` (`sortBy`, the `sort` macro, query param serialization, `isArray` and the container debug adapter), so framework code never reports the deprecation. A call to `isPresent` reports one deprecation, not one for each helper that it uses. The implementation tests now import from `lib/`, so they stay after the public API is removed. A new test checks the deprecation for each public function. The macro tests expect the deprecation and are skipped once the deprecation is removed. Co-authored-by: Peter Wagenet <[email protected]> Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The deprecation message and the `@deprecated` tags no longer name `@ember/legacy-utils`. The package is not on npm, and the migration path is native JavaScript. The deprecation guide explains it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Why are we keeping private undeprecated implementations around? IMO the internal usage of these should fire deprecations and should therefore also get fixed in this PR. When the deprecation hits removal, the whole |
Review feedback: the whole `@ember/utils` package must go away at removal, so no undeprecated copy of it stays for Ember's own code. - Each function in `@ember/utils/lib` reports the deprecation itself. The API docs stay where they were, and `index.ts` is back to plain re-exports. - Calls between the utils report too. For example, `isPresent` also reports `isBlank` and `isEmpty`. All of them use the same id. - `sortBy` and the `sort` computed macro use a native comparator: `undefined` first, then `null`, then strings, numbers, booleans and dates by value. Other pairs, such as mixed types, keep their order. - `isArray`, the container debug adapter and query param serialization use native checks. `defaultValueType` for the query param hooks keeps the names `null`, `array` and `date`, and uses `typeof` for other values. - The deprecated `empty`, `notEmpty` and `none` macros still call `isEmpty` and `isNone`, so they also report those. - The util tests expect the deprecation and are skipped after removal. Two new `sortBy` tests cover the new order. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
the timing of this is a little suboptiomal, as the things that use this are also being deprecated for v8.
it does keep the deprecation messages de-duplicated for users tho
| queryParams[key] = this._serializeQueryParam(value, typeOf(value)); | ||
| queryParams[key] = this._serializeQueryParam( | ||
| value, | ||
| Array.isArray(value) ? 'array' : typeof value |
There was a problem hiding this comment.
little cleanup here so we don't use @ember/utils internally
There was a problem hiding this comment.
This doesn't need to be the same as the other spot where queryParamType came into existance?
Every file under `packages/` is a rollup entrypoint, so the new `@ember/array/lib/sort-compare.ts` became an importable module in `renamed-modules`. It is a private helper, so rollup now bundles it into a shared chunk instead. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
@ef4 thanks, updated |
|
|
||
| const UTILS = DEPRECATIONS.DEPRECATE_EMBER_UTILS; | ||
|
|
||
| moduleFor( |
There was a problem hiding this comment.
Should we just guard the entire module?
There was a problem hiding this comment.
is there an advantage?
(I also didn't know we could do this -- does testUnless work on the moduleFor string / first param?)
There was a problem hiding this comment.
We've done it elsewhere, not with testUnless, just with an if (iirc).
Only advantage is brevity and/or easier to see the entire thing gets removed. I wouldn't necessarily update this PR but more of bringing it up as an option for later.
| function and false if the underlying value is not empty. | ||
|
|
||
| @public | ||
| @deprecated Use a getter instead. |
There was a problem hiding this comment.
I wonder if we should start putting links to the deprecation guides in the docs
There was a problem hiding this comment.
i like this idea -- I can do that in a separate pass and add links for all the shipped deprecations so far
Covers `compare`, `isBlank`, `isEmpty`, `isEqual`, `isNone`, `isPresent` and `typeOf` from `@ember/utils`, and the `empty`, `notEmpty` and `none` computed macros. Every migration uses native JavaScript. Replaces #1417. The id and versions match emberjs/ember.js#21632. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Implements RFC 334. Finishes and supersedes #20968 by @wagenet.
One deprecation id,
deprecate-ember-utils, covers the ten APIs in the RFC:compare,isBlank,isEmpty,isEqual,isNone,isPresentandtypeOffrom@ember/utilsempty,notEmptyandnonefrom@ember/object/computedIt is available in 7.5.0, with
until: 8.0.0. It is not enabled, because the RFC is not at Ready for Release yet (emberjs/rfcs#1056). After that merges, addenabledtoDEPRECATE_EMBER_UTILS.The deprecation guide is ember-learn/deprecation-app#1438.
How it works
@ember/utils/libreports the deprecation. The messages say "Use native JavaScript instead", and the macros say "Use a getter instead".@ember/utils, so the whole package can be deleted at removal. The only callers left are the three deprecated macros, which go at the same time.isPresentalso reportsisBlankandisEmpty, andcomparereportstypeOf. All of them use the same id.@deprecated.Behavior changes outside the deprecation
These call sites used
compareortypeOfand now use native code:sortByand thesortcomputed macro:undefinedfirst, thennull, then strings (localeCompare), numbers, booleans and dates by value. Other pairs keep their order. Before,comparealso ordered mixed types by type, compared arrays item by item, and usedComparable.isArray: anEmberObjectinstance with a numericlength, that is not anEmberArray, now returnstrue. Before,typeOfreturned'instance'for it.FileListandStringobjects still returnfalse.defaultValueTypein the query param hooks:null,arrayanddatekeep their names, and other values gettypeof. Before, a default value that was anEmberObjectinstance got'instance', and aRegExpgot'regexp'.CoreObject.detect, which is whattypeOfused for'class'. No change.Decisions to review
deprecate-eventedfor RFC 1111. The RFC text lists one id per function in an old format.Overlap
@ember/object/computedmacros, with its own ids. If both merge,empty,notEmptyandnonereport two ids.Testing
ALL_DEPRECATIONS_ENABLED(9,481 passed),OVERRIDE_DEPRECATION_VERSION=15.0.0(8,158 passed, 577 skipped).type-check:internals, eslint and prettier pass on the changed files.🤖 Generated with Claude Code