UNPKG

3.89 kBTypeScriptView Raw
1/// <amd-module name="@angular/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory" />
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9import ts from 'typescript';
10import { AstFactory, BinaryOperator, LeadingComment, ObjectLiteralProperty, SourceMapRange, TemplateLiteral, UnaryOperator, VariableDeclarationType } from './api/ast_factory';
11/**
12 * A TypeScript flavoured implementation of the AstFactory.
13 */
14export declare class TypeScriptAstFactory implements AstFactory<ts.Statement, ts.Expression> {
15 private annotateForClosureCompiler;
16 private externalSourceFiles;
17 constructor(annotateForClosureCompiler: boolean);
18 attachComments: typeof attachComments;
19 createArrayLiteral: (elements?: readonly ts.Expression[] | undefined, multiLine?: boolean | undefined) => ts.ArrayLiteralExpression;
20 createAssignment(target: ts.Expression, value: ts.Expression): ts.Expression;
21 createBinaryExpression(leftOperand: ts.Expression, operator: BinaryOperator, rightOperand: ts.Expression): ts.Expression;
22 createBlock(body: ts.Statement[]): ts.Statement;
23 createCallExpression(callee: ts.Expression, args: ts.Expression[], pure: boolean): ts.Expression;
24 createConditional: {
25 (condition: ts.Expression, whenTrue: ts.Expression, whenFalse: ts.Expression): ts.ConditionalExpression;
26 (condition: ts.Expression, questionToken: ts.QuestionToken, whenTrue: ts.Expression, colonToken: ts.ColonToken, whenFalse: ts.Expression): ts.ConditionalExpression;
27 };
28 createElementAccess: (expression: ts.Expression, index: number | ts.Expression) => ts.ElementAccessExpression;
29 createExpressionStatement: (expression: ts.Expression) => ts.ExpressionStatement;
30 createFunctionDeclaration(functionName: string, parameters: string[], body: ts.Statement): ts.Statement;
31 createFunctionExpression(functionName: string | null, parameters: string[], body: ts.Statement): ts.Expression;
32 createIdentifier: (text: string) => ts.Identifier;
33 createIfStatement(condition: ts.Expression, thenStatement: ts.Statement, elseStatement: ts.Statement | null): ts.Statement;
34 createLiteral(value: string | number | boolean | null | undefined): ts.Expression;
35 createNewExpression(expression: ts.Expression, args: ts.Expression[]): ts.Expression;
36 createObjectLiteral(properties: ObjectLiteralProperty<ts.Expression>[]): ts.Expression;
37 createParenthesizedExpression: (expression: ts.Expression) => ts.ParenthesizedExpression;
38 createPropertyAccess: (expression: ts.Expression, name: string | ts.MemberName) => ts.PropertyAccessExpression;
39 createReturnStatement(expression: ts.Expression | null): ts.Statement;
40 createTaggedTemplate(tag: ts.Expression, template: TemplateLiteral<ts.Expression>): ts.Expression;
41 createThrowStatement: (expression: ts.Expression) => ts.ThrowStatement;
42 createTypeOfExpression: (expression: ts.Expression) => ts.TypeOfExpression;
43 createUnaryExpression(operator: UnaryOperator, operand: ts.Expression): ts.Expression;
44 createVariableDeclaration(variableName: string, initializer: ts.Expression | null, type: VariableDeclarationType): ts.Statement;
45 setSourceMapRange<T extends ts.Node>(node: T, sourceMapRange: SourceMapRange | null): T;
46}
47export declare function createTemplateMiddle(cooked: string, raw: string): ts.TemplateMiddle;
48export declare function createTemplateTail(cooked: string, raw: string): ts.TemplateTail;
49/**
50 * Attach the given `leadingComments` to the `statement` node.
51 *
52 * @param statement The statement that will have comments attached.
53 * @param leadingComments The comments to attach to the statement.
54 */
55export declare function attachComments(statement: ts.Statement, leadingComments: LeadingComment[]): void;