Skip to content

Implement RFC #334: Deprecate @ember/utils and the empty, notEmpty, none macros - #21632

Merged
NullVoxPopuli merged 4 commits into
emberjs:mainfrom
NullVoxPopuli-ai-agent:nvp/deprecate-ember-utils
Oct 1, 2026
Merged

NullVoxPopuli merged 4 commits into
emberjs:mainfrom
NullVoxPopuli-ai-agent:nvp/deprecate-ember-utils

Conversation

@NullVoxPopuli-ai-agent

@NullVoxPopuli-ai-agent NullVoxPopuli-ai-agent commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

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, isPresent and typeOf from @ember/utils
  • empty, notEmpty and none from @ember/object/computed

It 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, add enabled to DEPRECATE_EMBER_UTILS.

The deprecation guide is ember-learn/deprecation-app#1438.

How it works

  • Each function in @ember/utils/lib reports the deprecation. The messages say "Use native JavaScript instead", and the macros say "Use a getter instead".
  • Ember no longer uses @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.
  • Calls between the utils report too. For example, isPresent also reports isBlank and isEmpty, and compare reports typeOf. All of them use the same id.
  • The API docs and the published types mark all ten APIs @deprecated.

Behavior changes outside the deprecation

These call sites used compare or typeOf and now use native code:

  • sortBy and the sort computed macro: undefined first, then null, then strings (localeCompare), numbers, booleans and dates by value. Other pairs keep their order. Before, compare also ordered mixed types by type, compared arrays item by item, and used Comparable.
  • isArray: an EmberObject instance with a numeric length, that is not an EmberArray, now returns true. Before, typeOf returned 'instance' for it. FileList and String objects still return false.
  • defaultValueType in the query param hooks: null, array and date keep their names, and other values get typeof. Before, a default value that was an EmberObject instance got 'instance', and a RegExp got 'regexp'.
  • The container debug adapter uses CoreObject.detect, which is what typeOf used for 'class'. No change.

Decisions to review

  1. One id for all ten APIs, the same as deprecate-evented for RFC 1111. The RFC text lists one id per function in an old format.
  2. Nested calls report more than one deprecation, instead of keeping undeprecated copies of the utils.

Overlap

Testing

  • Full browser suite on the head commit, 0 failures in each mode: default (9,481 passed), 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

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]>
Comment thread packages/@ember/utils/lib/compare.ts Resolved
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]>
@ef4

ef4 commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

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 @ember/util package should be gone.

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]>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

little cleanup here so we don't use @ember/utils internally

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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]>
@NullVoxPopuli

Copy link
Copy Markdown
Contributor

@ef4 thanks, updated


const UTILS = DEPRECATIONS.DEPRECATE_EMBER_UTILS;

moduleFor(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we just guard the entire module?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is there an advantage?

(I also didn't know we could do this -- does testUnless work on the moduleFor string / first param?)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

tyty <3

function and false if the underlying value is not empty.

@public
@deprecated Use a getter instead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if we should start putting links to the deprecation guides in the docs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i like this idea -- I can do that in a separate pass and add links for all the shipped deprecations so far

@NullVoxPopuli
NullVoxPopuli merged commit 1216eb5 into emberjs:main Oct 1, 2026
69 checks passed
@NullVoxPopuli
NullVoxPopuli deleted the nvp/deprecate-ember-utils branch October 1, 2026 15:50
@github-actions github-actions Bot mentioned this pull request Oct 1, 2026
kategengler pushed a commit to ember-learn/deprecation-app that referenced this pull request Oct 19, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants