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/metadata/evaluator" />
|
---|
9 | import * as ts from 'typescript';
|
---|
10 | import { CollectorOptions } from './collector';
|
---|
11 | import { MetadataEntry, MetadataError, MetadataValue } from './schema';
|
---|
12 | import { Symbols } from './symbols';
|
---|
13 | export declare function isPrimitive(value: any): boolean;
|
---|
14 | export interface ImportSpecifierMetadata {
|
---|
15 | name: string;
|
---|
16 | propertyName?: string;
|
---|
17 | }
|
---|
18 | export interface ImportMetadata {
|
---|
19 | defaultName?: string;
|
---|
20 | namespace?: string;
|
---|
21 | namedImports?: ImportSpecifierMetadata[];
|
---|
22 | from: string;
|
---|
23 | }
|
---|
24 | /**
|
---|
25 | * Produce a symbolic representation of an expression folding values into their final value when
|
---|
26 | * possible.
|
---|
27 | */
|
---|
28 | export declare class Evaluator {
|
---|
29 | private symbols;
|
---|
30 | private nodeMap;
|
---|
31 | private options;
|
---|
32 | private recordExport?;
|
---|
33 | constructor(symbols: Symbols, nodeMap: Map<MetadataEntry, ts.Node>, options?: CollectorOptions, recordExport?: ((name: string, value: MetadataValue) => void) | undefined);
|
---|
34 | nameOf(node: ts.Node | undefined): string | MetadataError;
|
---|
35 | /**
|
---|
36 | * Returns true if the expression represented by `node` can be folded into a literal expression.
|
---|
37 | *
|
---|
38 | * For example, a literal is always foldable. This means that literal expressions such as `1.2`
|
---|
39 | * `"Some value"` `true` `false` are foldable.
|
---|
40 | *
|
---|
41 | * - An object literal is foldable if all the properties in the literal are foldable.
|
---|
42 | * - An array literal is foldable if all the elements are foldable.
|
---|
43 | * - A call is foldable if it is a call to a Array.prototype.concat or a call to CONST_EXPR.
|
---|
44 | * - A property access is foldable if the object is foldable.
|
---|
45 | * - A array index is foldable if index expression is foldable and the array is foldable.
|
---|
46 | * - Binary operator expressions are foldable if the left and right expressions are foldable and
|
---|
47 | * it is one of '+', '-', '*', '/', '%', '||', and '&&'.
|
---|
48 | * - An identifier is foldable if a value can be found for its symbol in the evaluator symbol
|
---|
49 | * table.
|
---|
50 | */
|
---|
51 | isFoldable(node: ts.Node): boolean;
|
---|
52 | private isFoldableWorker;
|
---|
53 | /**
|
---|
54 | * Produce a JSON serialiable object representing `node`. The foldable values in the expression
|
---|
55 | * tree are folded. For example, a node representing `1 + 2` is folded into `3`.
|
---|
56 | */
|
---|
57 | evaluateNode(node: ts.Node, preferReference?: boolean): MetadataValue;
|
---|
58 | }
|
---|