|
3 | 3 | // of @cached, so any changes made to one should also be made to the other |
4 | 4 | import { assert } from '@ember/debug'; |
5 | 5 | import { DEBUG } from '@glimmer/env'; |
6 | | -import { type CachedValue, cachedValue } from '@glimmer/validator/lib/cached-value'; |
| 6 | +import { cachedValue } from '@glimmer/validator/lib/cached-value'; |
| 7 | +import type { ReadOnlyReactive } from '@glimmer/validator/lib/tracked-value'; |
7 | 8 | import { createCache, getValue } from '@glimmer/validator/lib/tracking'; |
8 | 9 |
|
9 | 10 | /** |
@@ -142,16 +143,19 @@ export function cached<T>( |
142 | 143 | * `cached` as a standalone cached reactive value, usable outside of classes: |
143 | 144 | * `const doubled = cached(() => count.value * 2)`. |
144 | 145 | */ |
145 | | -export function cached<Value>(fn: () => Value, options?: CachedValueOptions): CachedValue<Value>; |
146 | | -export function cached(...args: any[]): CachedValue<unknown> | void { |
| 146 | +export function cached<Value>( |
| 147 | + fn: () => Value, |
| 148 | + options?: CachedValueOptions |
| 149 | +): ReadOnlyReactive<Value>; |
| 150 | +export function cached(...args: any[]): ReadOnlyReactive<unknown> | void { |
147 | 151 | const [target, key, descriptor] = args; |
148 | 152 |
|
149 | 153 | // Error on `@cached()`, `@cached(...args)`, and `@cached propName = value;` |
150 | 154 | if (DEBUG && target === undefined) throwCachedExtraneousParens(); |
151 | 155 |
|
152 | 156 | if (typeof target === 'function' && args.length <= 2) { |
153 | 157 | /* |
154 | | - Standalone form. Returns a read-only `CachedValue` usable outside of |
| 158 | + Standalone form. Returns a `ReadOnlyReactive` usable outside of |
155 | 159 | classes. A legacy decorator invocation always receives three arguments, |
156 | 160 | so it can never land in this branch. |
157 | 161 |
|
|
0 commit comments