@frontic/nuxt 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,14 +5,20 @@ import type { FronticRequestOptions } from '../types/listing.js';
|
|
|
5
5
|
* Extracts the `items` array type from a tree response.
|
|
6
6
|
*
|
|
7
7
|
* When the user has a generated client, `Responses[T]` resolves to the concrete
|
|
8
|
-
* tree response shape (`{ items
|
|
8
|
+
* tree response shape (`{ items?: TreeNode[] }`) and this gives back the typed
|
|
9
9
|
* node array — so consumers get full IDE autocomplete on `node.$items`,
|
|
10
10
|
* `node.key`, and the block fields. Falls back to `unknown[]` against the
|
|
11
11
|
* ambient `Responses { [key: string]: unknown }` declaration.
|
|
12
|
+
*
|
|
13
|
+
* The generated `items` property is optional (the API may omit it), so the
|
|
14
|
+
* conditional matches `items?:` and strips `undefined` from the inferred type.
|
|
15
|
+
* The `unknown extends I` guard handles the ambient case where `TResponse` is
|
|
16
|
+
* `unknown` and `I` is inferred as `unknown`: without it, the branch would
|
|
17
|
+
* return bare `unknown` instead of the intended `unknown[]` array fallback.
|
|
12
18
|
*/
|
|
13
|
-
type TreeItems<TResponse> = TResponse extends {
|
|
14
|
-
items
|
|
15
|
-
} ? I : unknown[];
|
|
19
|
+
type TreeItems<TResponse> = [TResponse] extends [{
|
|
20
|
+
items?: infer I;
|
|
21
|
+
}] ? (unknown extends I ? unknown[] : Exclude<I, undefined>) : unknown[];
|
|
16
22
|
export interface UseFronticTreeOptions extends FronticRequestOptions {
|
|
17
23
|
/**
|
|
18
24
|
* Optional starting node key. When provided, the response contains the
|
package/package.json
CHANGED