ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
167 lines (166 loc) • 8.1 kB
TypeScript
import * as ts from "typescript";
import { PropertyAssignmentStructure, ShorthandPropertyAssignmentStructure, SpreadAssignmentStructure, MethodDeclarationStructure, GetAccessorDeclarationStructure, SetAccessorDeclarationStructure } from "./../../../structures";
import { ObjectLiteralElementLike } from "./../../aliases";
import { MethodDeclaration, GetAccessorDeclaration, SetAccessorDeclaration } from "./../../class";
import { Expression } from "./../Expression";
import { PropertyAssignment } from "./PropertyAssignment";
import { ShorthandPropertyAssignment } from "./ShorthandPropertyAssignment";
import { SpreadAssignment } from "./SpreadAssignment";
export declare class ObjectLiteralExpression extends Expression<ts.ObjectLiteralExpression> {
/**
* Gets the first property by the provided name or throws.
* @param name - Name of the property.
*/
getPropertyOrThrow(name: string): ObjectLiteralElementLike;
/**
* Gets the first property that matches the provided find function or throws.
* @param findFunction - Find function.
*/
getPropertyOrThrow(findFunction: (property: ObjectLiteralElementLike) => boolean): ObjectLiteralElementLike;
/**
* Gets the first property by the provided name or returns undefined.
* @param name - Name of the property.
*/
getProperty(name: string): ObjectLiteralElementLike | undefined;
/**
* Gets the first property that matches the provided find function or returns undefined.
* @param findFunction - Find function.
*/
getProperty(findFunction: (property: ObjectLiteralElementLike) => boolean): ObjectLiteralElementLike | undefined;
/**
* Gets the properties.
*/
getProperties(): ObjectLiteralElementLike[];
/**
* Adds a property assignment.
* @param structure - Structure that represents the property assignment to add.
*/
addPropertyAssignment(structure: PropertyAssignmentStructure): PropertyAssignment;
/**
* Adds property assignments.
* @param structures - Structure that represents the property assignments to add.
*/
addPropertyAssignments(structures: PropertyAssignmentStructure[]): PropertyAssignment[];
/**
* Inserts a property assignment at the specified index.
* @param index - Index to insert.
* @param structure - Structure that represents the property assignment to insert.
*/
insertPropertyAssignment(index: number, structure: PropertyAssignmentStructure): PropertyAssignment;
/**
* Inserts property assignments at the specified index.
* @param index - Index to insert.
* @param structures - Structures that represent the property assignments to insert.
*/
insertPropertyAssignments(index: number, structures: PropertyAssignmentStructure[]): PropertyAssignment[];
/**
* Adds a shorthand property assignment.
* @param structure - Structure that represents the shorthand property assignment to add.
*/
addShorthandPropertyAssignment(structure: ShorthandPropertyAssignmentStructure): ShorthandPropertyAssignment;
/**
* Adds shorthand property assignments.
* @param structures - Structure that represents the shorthand property assignments to add.
*/
addShorthandPropertyAssignments(structures: ShorthandPropertyAssignmentStructure[]): ShorthandPropertyAssignment[];
/**
* Inserts a shorthand property assignment at the specified index.
* @param index - Index to insert.
* @param structure - Structure that represents the shorthand property assignment to insert.
*/
insertShorthandPropertyAssignment(index: number, structure: ShorthandPropertyAssignmentStructure): ShorthandPropertyAssignment;
/**
* Inserts shorthand property assignments at the specified index.
* @param index - Index to insert.
* @param structures - Structures that represent the shorthand property assignments to insert.
*/
insertShorthandPropertyAssignments(index: number, structures: ShorthandPropertyAssignmentStructure[]): ShorthandPropertyAssignment[];
/**
* Adds a spread assignment.
* @param structure - Structure that represents the spread assignment to add.
*/
addSpreadAssignment(structure: SpreadAssignmentStructure): SpreadAssignment;
/**
* Adds spread assignments.
* @param structures - Structure that represents the spread assignments to add.
*/
addSpreadAssignments(structures: SpreadAssignmentStructure[]): SpreadAssignment[];
/**
* Inserts a spread assignment at the specified index.
* @param index - Index to insert.
* @param structure - Structure that represents the spread assignment to insert.
*/
insertSpreadAssignment(index: number, structure: SpreadAssignmentStructure): SpreadAssignment;
/**
* Inserts spread assignments at the specified index.
* @param index - Index to insert.
* @param structures - Structures that represent the spread assignments to insert.
*/
insertSpreadAssignments(index: number, structures: SpreadAssignmentStructure[]): SpreadAssignment[];
/**
* Adds a method.
* @param structure - Structure that represents the method to add.
*/
addMethod(structure: MethodDeclarationStructure): MethodDeclaration;
/**
* Adds methods.
* @param structures - Structure that represents the methods to add.
*/
addMethods(structures: MethodDeclarationStructure[]): MethodDeclaration[];
/**
* Inserts a method at the specified index.
* @param index - Index to insert.
* @param structure - Structure that represents the method to insert.
*/
insertMethod(index: number, structure: MethodDeclarationStructure): MethodDeclaration;
/**
* Inserts methods at the specified index.
* @param index - Index to insert.
* @param structures - Structures that represent the methods to insert.
*/
insertMethods(index: number, structures: MethodDeclarationStructure[]): MethodDeclaration[];
/**
* Adds a get accessor.
* @param structure - Structure that represents the property assignment to add.
*/
addGetAccessor(structure: GetAccessorDeclarationStructure): GetAccessorDeclaration;
/**
* Adds get accessors.
* @param structures - Structure that represents the get accessors to add.
*/
addGetAccessors(structures: GetAccessorDeclarationStructure[]): GetAccessorDeclaration[];
/**
* Inserts a get accessor at the specified index.
* @param index - Index to insert.
* @param structure - Structure that represents the get accessor to insert.
*/
insertGetAccessor(index: number, structure: GetAccessorDeclarationStructure): GetAccessorDeclaration;
/**
* Inserts get accessors at the specified index.
* @param index - Index to insert.
* @param structures - Structures that represent the get accessors to insert.
*/
insertGetAccessors(index: number, structures: GetAccessorDeclarationStructure[]): GetAccessorDeclaration[];
/**
* Adds a set accessor.
* @param structure - Structure that represents the property assignment to add.
*/
addSetAccessor(structure: SetAccessorDeclarationStructure): SetAccessorDeclaration;
/**
* Adds set accessors.
* @param structures - Structure that represents the set accessors to add.
*/
addSetAccessors(structures: SetAccessorDeclarationStructure[]): SetAccessorDeclaration[];
/**
* Inserts a set accessor at the specified index.
* @param index - Index to insert.
* @param structure - Structure that represents the set accessor to insert.
*/
insertSetAccessor(index: number, structure: SetAccessorDeclarationStructure): SetAccessorDeclaration;
/**
* Inserts set accessors at the specified index.
* @param index - Index to insert.
* @param structures - Structures that represent the set accessors to insert.
*/
insertSetAccessors(index: number, structures: SetAccessorDeclarationStructure[]): SetAccessorDeclaration[];
}