import { IParser } from "./i-parser"; import { Block, Expression, Node, NodeArray, Statement, TypeNode, TypeParameterDeclaration } from "typescript"; import { ITypescriptASTUtil } from "@wessberg/typescript-ast-util"; /** * A class that helps with parsing string expressions into proper Nodes */ export declare class Parser implements IParser { private readonly astUtil; /** * The filename to use when generating a SourceFile from an expression * @type {string} */ private static readonly FILENAME; /** * The ScriptTarget to use when generating a SourceFile from an expression * @type {ScriptTarget.ES2017} */ private static readonly SCRIPT_TARGET; constructor(astUtil: ITypescriptASTUtil); /** * Parses the provided expression string into an Expression * @param {string} expression * @returns {Expression} */ parseExpression(expression: string): Expression; /** * Parses a Statement * @param {string} statement * @returns {Statement} */ parseStatement(statement: string): Statement; /** * Parses the provided string into a Block * @param {string} block * @returns {Block} */ parseBlock(block: string): Block; /** * Parses the provided expression statement into a Node * @param {string} expression * @returns {T} */ parseOne(expression: string): T; /** * Parses the provided expression into a NodeArray of Statements * @template T * @param {string} expression * @returns {NodeArray} */ parse(expression: string): NodeArray; /** * Parses a type into a TypeNode * @param {string} type * @returns {ts.TypeNode} */ parseType(type: string): TypeNode; /** * Parses a TypeParameterDe * @param {string} type * @returns {TypeParameterDeclaration} */ parseTypeParameterDeclaration(type: string): TypeParameterDeclaration; /** * Gets a test function signature. Needed to make Typescripts parser generate Type-specific nodes * @param {string} type * @returns {string} */ private getTestTypeFunctionSignature; /** * Gets a test function signature for type parameters. Needed to make Typescripts parser generate Type-specific nodes * @param {string} typeParameter * @returns {string} */ private getTestTypeParameterDeclarationFunctionSignature; /** * Gets a test function with a function body equal to the provided block * @param {string} block * @returns {string} */ private getTestBlockFunction; /** * Gets a test function which can return an expression block * @param {string} expression * @returns {string} */ private getTestExpressionFunction; }