-
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathparsedCache.ts
More file actions
29 lines (22 loc) · 1008 Bytes
/
parsedCache.ts
File metadata and controls
29 lines (22 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import {EntityAttribute, NodeScope, NodeType} from "./nodes";
export enum ParsedCacheKind {
EntityAttribute = 'EntityAttribute',
Scope = 'Scope',
TypeTemplates = 'TypeTemplates',
}
export type ParsedCacheTargets<T extends ParsedCacheKind> = TargetEntityAttribute<T>;
type TargetEntityAttribute<T extends ParsedCacheKind> =
T extends ParsedCacheKind.EntityAttribute ? EntityAttribute : TargetScope<T>;
type TargetScope<T extends ParsedCacheKind> =
T extends ParsedCacheKind.Scope ? NodeScope : TargetTypeTemplates<T>;
type TargetTypeTemplates<T extends ParsedCacheKind> =
T extends ParsedCacheKind.TypeTemplates ? NodeType[] : never;
export interface ParsedCachedData<T extends ParsedCacheKind> {
kind: T;
rangeEnd: number;
data: ParsedCacheTargets<T> | undefined;
}
export interface ParsedCacheServices<T extends ParsedCacheKind> {
restore: (() => ParsedCacheTargets<T> | undefined) | undefined;
store: (cache: ParsedCacheTargets<T> | undefined) => void;
}