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