UNPKG

3.45 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google Inc. 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 */
8import { ConstantPool } from './constant_pool';
9import * as o from './output/output_ast';
10import { ParseError } from './parse_util';
11export declare function dashCaseToCamelCase(input: string): string;
12export declare function splitAtColon(input: string, defaultValues: string[]): string[];
13export declare function splitAtPeriod(input: string, defaultValues: string[]): string[];
14export declare function visitValue(value: any, visitor: ValueVisitor, context: any): any;
15export declare function isDefined(val: any): boolean;
16export declare function noUndefined<T>(val: T | undefined): T;
17export interface ValueVisitor {
18 visitArray(arr: any[], context: any): any;
19 visitStringMap(map: {
20 [key: string]: any;
21 }, context: any): any;
22 visitPrimitive(value: any, context: any): any;
23 visitOther(value: any, context: any): any;
24}
25export declare class ValueTransformer implements ValueVisitor {
26 visitArray(arr: any[], context: any): any;
27 visitStringMap(map: {
28 [key: string]: any;
29 }, context: any): any;
30 visitPrimitive(value: any, context: any): any;
31 visitOther(value: any, context: any): any;
32}
33export declare type SyncAsync<T> = T | Promise<T>;
34export declare const SyncAsync: {
35 assertSync: <T>(value: SyncAsync<T>) => T;
36 then: <T_1, R>(value: SyncAsync<T_1>, cb: (value: T_1) => R | Promise<R> | Promise<R>) => SyncAsync<R>;
37 all: <T_2>(syncAsyncValues: SyncAsync<T_2>[]) => SyncAsync<T_2[]>;
38};
39export declare function error(msg: string): never;
40export declare function syntaxError(msg: string, parseErrors?: ParseError[]): Error;
41export declare function isSyntaxError(error: Error): boolean;
42export declare function getParseErrors(error: Error): ParseError[];
43export declare function escapeRegExp(s: string): string;
44export declare function utf8Encode(str: string): string;
45export interface OutputContext {
46 genFilePath: string;
47 statements: o.Statement[];
48 constantPool: ConstantPool;
49 importExpr(reference: any, typeParams?: o.Type[] | null, useSummaries?: boolean): o.Expression;
50}
51export declare function stringify(token: any): string;
52/**
53 * Lazily retrieves the reference value from a forwardRef.
54 */
55export declare function resolveForwardRef(type: any): any;
56/**
57 * Determine if the argument is shaped like a Promise
58 */
59export declare function isPromise<T = any>(obj: any): obj is Promise<T>;
60export declare class Version {
61 full: string;
62 readonly major: string;
63 readonly minor: string;
64 readonly patch: string;
65 constructor(full: string);
66}
67export interface Console {
68 log(message: string): void;
69 warn(message: string): void;
70}
71declare const _global: {
72 [name: string]: any;
73};
74export { _global as global };
75export declare function newArray<T = any>(size: number): T[];
76export declare function newArray<T>(size: number, value: T): T[];
77/**
78 * Partitions a given array into 2 arrays, based on a boolean value returned by the condition
79 * function.
80 *
81 * @param arr Input array that should be partitioned
82 * @param conditionFn Condition function that is called for each item in a given array and returns a
83 * boolean value.
84 */
85export declare function partitionArray<T>(arr: T[], conditionFn: <K extends T>(value: K) => boolean): [T[], T[]];