UNPKG

2.5 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8/// <amd-module name="@angular/compiler-cli/src/ngtsc/partial_evaluator/src/result" />
9import ts from 'typescript';
10import { Reference } from '../../imports';
11import { Declaration } from '../../reflection';
12import { DynamicValue } from './dynamic';
13/**
14 * A value resulting from static resolution.
15 *
16 * This could be a primitive, collection type, reference to a `ts.Node` that declares a
17 * non-primitive value, or a special `DynamicValue` type which indicates the value was not
18 * available statically.
19 */
20export declare type ResolvedValue = number | boolean | string | null | undefined | Reference | EnumValue | ResolvedValueArray | ResolvedValueMap | ResolvedModule | KnownFn | DynamicValue<unknown>;
21/**
22 * An array of `ResolvedValue`s.
23 *
24 * This is a reified type to allow the circular reference of `ResolvedValue` -> `ResolvedValueArray`
25 * -> `ResolvedValue`.
26 */
27export interface ResolvedValueArray extends Array<ResolvedValue> {
28}
29/**
30 * A map of strings to `ResolvedValue`s.
31 *
32 * This is a reified type to allow the circular reference of `ResolvedValue` -> `ResolvedValueMap`
33 * -> `ResolvedValue`.
34 */
35export interface ResolvedValueMap extends Map<string, ResolvedValue> {
36}
37/**
38 * A collection of publicly exported declarations from a module. Each declaration is evaluated
39 * lazily upon request.
40 */
41export declare class ResolvedModule {
42 private exports;
43 private evaluate;
44 constructor(exports: Map<string, Declaration>, evaluate: (decl: Declaration) => ResolvedValue);
45 getExport(name: string): ResolvedValue;
46 getExports(): ResolvedValueMap;
47}
48/**
49 * A value member of an enumeration.
50 *
51 * Contains a `Reference` to the enumeration itself, and the name of the referenced member.
52 */
53export declare class EnumValue {
54 readonly enumRef: Reference<ts.Declaration>;
55 readonly name: string;
56 readonly resolved: ResolvedValue;
57 constructor(enumRef: Reference<ts.Declaration>, name: string, resolved: ResolvedValue);
58}
59/**
60 * An implementation of a known function that can be statically evaluated.
61 * It could be a built-in function or method (such as `Array.prototype.slice`) or a TypeScript
62 * helper (such as `__spread`).
63 */
64export declare abstract class KnownFn {
65 abstract evaluate(node: ts.CallExpression, args: ResolvedValueArray): ResolvedValue;
66}