UNPKG

4.46 kBTypeScriptView Raw
1import * as ts from 'typescript';
2export declare class TypeScriptHelpers {
3 private static readonly _wellKnownSymbolNameRegExp;
4 private static readonly _uniqueSymbolNameRegExp;
5 /**
6 * This traverses any symbol aliases to find the original place where an item was defined.
7 * For example, suppose a class is defined as "export default class MyClass { }"
8 * but exported from the package's index.ts like this:
9 *
10 * export { default as _MyClass } from './MyClass';
11 *
12 * In this example, calling followAliases() on the _MyClass symbol will return the
13 * original definition of MyClass, traversing any intermediary places where the
14 * symbol was imported and re-exported.
15 */
16 static followAliases(symbol: ts.Symbol, typeChecker: ts.TypeChecker): ts.Symbol;
17 /**
18 * Returns true if TypeScriptHelpers.followAliases() would return something different
19 * from the input `symbol`.
20 */
21 static isFollowableAlias(symbol: ts.Symbol, typeChecker: ts.TypeChecker): boolean;
22 /**
23 * Certain virtual symbols do not have any declarations. For example, `ts.TypeChecker.getExportsOfModule()` can
24 * sometimes return a "prototype" symbol for an object, even though there is no corresponding declaration in the
25 * source code. API Extractor generally ignores such symbols.
26 */
27 static tryGetADeclaration(symbol: ts.Symbol): ts.Declaration | undefined;
28 /**
29 * Returns true if the specified symbol is an ambient declaration.
30 */
31 static isAmbient(symbol: ts.Symbol, typeChecker: ts.TypeChecker): boolean;
32 /**
33 * Same semantics as tryGetSymbolForDeclaration(), but throws an exception if the symbol
34 * cannot be found.
35 */
36 static getSymbolForDeclaration(declaration: ts.Declaration, checker: ts.TypeChecker): ts.Symbol;
37 static getModuleSpecifier(nodeWithModuleSpecifier: ts.ImportDeclaration | ts.ExportDeclaration | ts.ImportTypeNode): string | undefined;
38 /**
39 * Returns an ancestor of "node", such that the ancestor, any intermediary nodes,
40 * and the starting node match a list of expected kinds. Undefined is returned
41 * if there aren't enough ancestors, or if the kinds are incorrect.
42 *
43 * For example, suppose child "C" has parents A --> B --> C.
44 *
45 * Calling _matchAncestor(C, [ExportSpecifier, NamedExports, ExportDeclaration])
46 * would return A only if A is of kind ExportSpecifier, B is of kind NamedExports,
47 * and C is of kind ExportDeclaration.
48 *
49 * Calling _matchAncestor(C, [ExportDeclaration]) would return C.
50 */
51 static matchAncestor<T extends ts.Node>(node: ts.Node, kindsToMatch: ts.SyntaxKind[]): T | undefined;
52 /**
53 * Does a depth-first search of the children of the specified node. Returns the first child
54 * with the specified kind, or undefined if there is no match.
55 */
56 static findFirstChildNode<T extends ts.Node>(node: ts.Node, kindToMatch: ts.SyntaxKind): T | undefined;
57 /**
58 * Returns the first parent node with the specified SyntaxKind, or undefined if there is no match.
59 */
60 static findFirstParent<T extends ts.Node>(node: ts.Node, kindToMatch: ts.SyntaxKind): T | undefined;
61 /**
62 * Returns the highest parent node with the specified SyntaxKind, or undefined if there is no match.
63 * @remarks
64 * Whereas findFirstParent() returns the first match, findHighestParent() returns the last match.
65 */
66 static findHighestParent<T extends ts.Node>(node: ts.Node, kindToMatch: ts.SyntaxKind): T | undefined;
67 /**
68 * Decodes the names that the compiler generates for a built-in ECMAScript symbol.
69 *
70 * @remarks
71 * TypeScript binds well-known ECMAScript symbols like `[Symbol.iterator]` as `__@iterator`.
72 * If `name` is of this form, then `tryGetWellKnownSymbolName()` converts it back into e.g. `[Symbol.iterator]`.
73 * If the string does not start with `__@` then `undefined` is returned.
74 */
75 static tryDecodeWellKnownSymbolName(name: ts.__String): string | undefined;
76 /**
77 * Returns whether the provided name was generated for a TypeScript `unique symbol`.
78 */
79 static isUniqueSymbolName(name: ts.__String): boolean;
80 /**
81 * Derives the string representation of a TypeScript late-bound symbol.
82 */
83 static tryGetLateBoundName(declarationName: ts.ComputedPropertyName): string | undefined;
84}
85//# sourceMappingURL=TypeScriptHelpers.d.ts.map
\No newline at end of file