/** * @license * Copyright 2021 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ import ts from 'typescript'; import type { Visitor } from './visitor.js'; /** * A transformer for Lit code. * * Configured with an array of visitors, each of which handles a specific Lit * feature such as a decorator. All visitors are invoked from a single pass * through each file. * * Files are only traversed at all if there is at least one feature imported * from an official Lit module (e.g. the "property" decorator), and there is a * registered visitor that declares it will handle that feature (e.g. the * PropertyVisitor). */ export declare class LitTransformer { private readonly _context; private readonly _classDecoratorVisitors; private readonly _memberDecoratorVisitors; private readonly _genericVisitors; private readonly _litFileContext; constructor(program: ts.Program, context: ts.TransformationContext, visitors: Array); private _registerVisitor; private _unregisterVisitor; visitFile: (node: ts.Node) => ts.VisitResult; visit: (node: ts.Node) => ts.VisitResult; /** * Add an entry to our "litImports" map for each relevant imported symbol, if * this is an import from an official Lit package. Returns whether or not * anything relevant was found. */ private _updateFileContextWithLitImports; private _visitImportDeclaration; private getDecorators; private _visitClassDeclaration; /** * Create the AST from e.g. `@property({type: String}) myProperty`: * * static get properties() { * return { * myProperty: { type: String }, * ... * } * } */ private _createStaticPropertiesExpression; private _findExistingStaticPropertiesExpression; /** * Create or modify a class constructor to add additional constructor * statements from any of our transforms. */ private _addExtraConstructorStatements; }