import * as ts from 'typescript'; import { OutputContext, Transpiler } from './main'; /** * Map from identifier name to resolved type. * Example: 'E' should map to a TypeNode for number when resolving a usage of MyArray * where MyArray is the alias type: * type MyArray = Array */ export declare type ResolvedTypeMap = Map; /*** * Options for how TypeScript types are represented as Dart types. */ export interface TypeDisplayOptions { insideComment?: boolean; insideTypeArgument?: boolean; hideComment?: boolean; /** * Type arguments associated with the current type to display. * Arguments are emitted directly in normal cases but in the case of type aliases we have to * propagate and substitute type arguments. */ typeArguments?: ts.NodeArray; /** * Parameter declarations to substitute. This is required to support type aliases with type * arguments that are not representable in Dart. */ resolvedTypeArguments?: ResolvedTypeMap; } /** * Summary information on what is imported via a particular import. */ export declare class ImportSummary { showAll: boolean; shown: Set; asPrefix: string; } export declare type Constructor = ts.ConstructorDeclaration | ts.ConstructSignatureDeclaration; export declare type ClassLike = ts.ClassLikeDeclaration | ts.InterfaceDeclaration; /** * Interface extending the true InterfaceDeclaration interface to add optional state we store on * interfaces to simplify conversion to Dart classes. */ export interface ExtendedInterfaceDeclaration extends ts.InterfaceDeclaration { /** * The type associated with this interface that we want to treat as the concrete location of this * interface to enable interfaces that act like constructors. Because Dart does not permit calling * objects like constructors we have to add this workaround. */ constructedType?: ts.InterfaceDeclaration | ts.TypeLiteralNode; } export declare function ident(n: ts.Node): string; export declare function isFunctionTypedefLikeInterface(ifDecl: ts.InterfaceDeclaration): boolean; export declare function isExtendsClause(heritageClause: ts.HeritageClause): boolean; export declare function isConstructor(n: ts.Node): n is Constructor; export declare function isStatic(n: ts.Node): boolean; export declare function isReadonly(n: ts.Node): boolean; export declare function isCallableType(type: ts.TypeNode, tc: ts.TypeChecker): boolean; /** * Returns whether a type declaration is on we can generate a named Dart type for. * For unsupported alias types we need to manually substitute the expression * the alias corresponds to in call sites. */ export declare function supportedTypeDeclaration(decl: ts.Declaration): boolean; export declare function isFunctionType(type: ts.TypeNode, tc: ts.TypeChecker): boolean; /** * Whether a parameter declaration is specifying information about the type of "this" passed to * the function instead of being a normal type parameter representable by a Dart type. */ export declare function isThisParameter(param: ts.ParameterDeclaration): boolean; /** * Dart does not have a concept of binding the type of the "this" parameter to a method. */ export declare function filterThisParameter(params: ts.NodeArray): ts.ParameterDeclaration[]; export declare function isTypeNode(node: ts.Node): boolean; export declare function isPromise(type: ts.TypeNode): boolean; export declare function isCallable(decl: ClassLike): boolean; export declare function copyLocation(src: ts.Node, dest: ts.Node): void; export declare function cloneNodeArray(src?: ts.NodeArray): ts.NodeArray | undefined; export declare function copyNodeArrayLocation(src: ts.TextRange, dest: ts.NodeArray): void; export declare function getAncestor(n: ts.Node, kind: ts.SyntaxKind): ts.Node; export declare function getEnclosingClass(n: ts.Node): ClassLike; export declare function isConstCall(node: ts.CallExpression): boolean; export declare function isInsideConstExpr(node: ts.Node): boolean; export declare function getModuleBlock(moduleDecl: ts.ModuleDeclaration): ts.ModuleBlock; /** * Determine the full module name including dots. * * e.g. returns 'foo.bar' for a declaration of namespace or module foo.bar */ export declare function getModuleName(moduleDecl: ts.ModuleDeclaration): string; export declare function formatType(s: string, comment: string, options: TypeDisplayOptions): string; export declare class TranspilerBase { protected transpiler: Transpiler; private idCounter; constructor(transpiler: Transpiler); visit(n: ts.Node): void; pushContext(context: OutputContext): void; popContext(): void; emit(s: string): void; emitNoSpace(s: string): void; emitType(s: string, comment: string): void; maybeLineBreak(): void; enterCodeComment(): void; exitCodeComment(): void; maybeWrapInCodeComment({ shouldWrap, newLine }: { shouldWrap?: boolean; newLine?: boolean; }, emit: () => void): void; enterTypeArguments(): void; exitTypeArguments(): void; get insideTypeArgument(): boolean; get insideCodeComment(): boolean; getImportSummary(libraryUri: string): ImportSummary; /** * Add an import. If an identifier is specified, only show that name. */ addImport(libraryUri: string, identifier?: string): ImportSummary; /** * Return resolved name possibly including a prefix for the identifier. */ resolveImportForSourceFile(sourceFile: ts.SourceFile, context: ts.SourceFile, identifier: string): string; reportError(n: ts.Node, message: string): void; visitNode(n: ts.Node): boolean; visitEach(nodes: ts.NodeArray): void; visitEachIfPresent(nodes?: ts.NodeArray): void; visitList(nodes: ts.NodeArray, separator?: string): void; /** * Returns whether any parameters were actually emitted. */ visitParameterList(nodes: ts.ParameterDeclaration[], namesOnly: boolean): boolean; uniqueId(name: string): string; assert(c: ts.Node, condition: boolean, reason: string): void; getAncestor(n: ts.Node, kind: ts.SyntaxKind): ts.Node; hasAncestor(n: ts.Node, kind: ts.SyntaxKind): boolean; hasAnnotation(decorators: ts.NodeArray, name: string): boolean; hasNodeFlag(n: ts.Declaration, flag: ts.NodeFlags): boolean; hasModifierFlag(n: ts.Declaration, flag: ts.ModifierFlags): boolean; getRelativeFileName(fileName: string): string; getDartFileName(fileName?: string): string; maybeVisitTypeArguments(n: { typeArguments?: ts.NodeArray; }): void; visitParameters(parameters: ts.NodeArray, { namesOnly }: { namesOnly?: boolean; }): void; }