Skip to content

Commit 00059be

Browse files
committed
Cast around more private/mixed support API usage
1 parent f0ef5fa commit 00059be

File tree

1 file changed

+14
-2
lines changed
  • addon/addon-test-support/@ember/test-helpers/-internal

1 file changed

+14
-2
lines changed

addon/addon-test-support/@ember/test-helpers/-internal/debug-info.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// @ts-ignore: this is private API. This import will work Ember 5.1+ since it
2+
// "provides" this public API, but does not for earlier versions. As a result,
3+
// this type will be `any`.
14
import { _backburner } from '@ember/runloop';
25
import { DebugInfo as BackburnerDebugInfo } from '@ember/runloop/-private/backburner';
36
import { DebugInfoHelper, debugInfoHelpers } from './debug-info-helpers';
@@ -109,7 +112,12 @@ export class TestDebugInfo implements DebugInfo {
109112
.filter(isNotNullable)
110113
.reduce((total, item) => {
111114
Object.values(item).forEach((queueItems) => {
112-
total += queueItems?.length ?? 0;
115+
// SAFETY: this cast is required for versions of Ember which do
116+
// not supply a correct definition of these types. It should
117+
// also be compatible with the version where Ember *does* supply
118+
// the types correctly.
119+
total +=
120+
(queueItems as Array<unknown> | undefined)?.length ?? 0;
113121
});
114122

115123
return total;
@@ -119,7 +127,11 @@ export class TestDebugInfo implements DebugInfo {
119127
.filter(isNotNullable)
120128
.reduce((stacks, deferredActionQueues) => {
121129
Object.values(deferredActionQueues).forEach((queueItems) => {
122-
queueItems?.forEach(
130+
// SAFETY: this cast is required for versions of Ember which do
131+
// not supply a correct definition of these types. It should
132+
// also be compatible with the version where Ember *does* supply
133+
// the types correctly.
134+
(queueItems as Array<{ stack: string }> | undefined)?.forEach(
123135
(queueItem) => queueItem.stack && stacks.push(queueItem.stack)
124136
);
125137
});

0 commit comments

Comments
 (0)