UNPKG

4.78 kBTypeScriptView Raw
1import ts from 'typescript';
2declare type NamedNode = ts.Node & {
3 readonly name: ts.Identifier;
4};
5declare type NameableNode = ts.Node & {
6 readonly name?: ts.Identifier;
7};
8export declare type PropertyNamedNode = ts.Node & {
9 readonly name: ts.PropertyName;
10};
11declare type PropertyNameableNode = ts.Node & {
12 readonly name?: ts.PropertyName;
13};
14declare type BindingNamedNode = ts.Node & {
15 readonly name: ts.BindingName;
16};
17declare type BindingNameableNode = ts.Node & {
18 readonly name?: ts.BindingName;
19};
20export declare type AnyNameableNode = NameableNode | PropertyNameableNode | BindingNameableNode;
21export declare function getNameNode(node: NamedNode): ts.Identifier;
22export declare function getNameNode(node: PropertyNamedNode): ts.PropertyName;
23export declare function getNameNode(node: BindingNamedNode): ts.BindingName;
24export declare function getNameNode(node: NameableNode): ts.Identifier | undefined;
25export declare function getNameNode(node: PropertyNameableNode): ts.PropertyName | undefined;
26export declare function getNameNode(node: BindingNameableNode): ts.BindingName | undefined;
27export declare function getNameNode(node: AnyNameableNode): ts.Identifier | ts.PropertyName | ts.BindingName | undefined;
28export declare function getNameNodeOrThrow(node: NameableNode | NamedNode): ts.Identifier;
29export declare function getNameNodeOrThrow(node: PropertyNameableNode | PropertyNamedNode): ts.PropertyName;
30export declare function getNameNodeOrThrow(node: BindingNameableNode | BindingNamedNode): ts.BindingName;
31export declare function getName(node: NamedNode | PropertyNamedNode): string;
32export declare function getName(node: NameableNode | PropertyNameableNode | BindingNameableNode | BindingNamedNode): string | undefined;
33export declare function getNameOrThrow(node: NameableNode | NamedNode | PropertyNameableNode | PropertyNamedNode | BindingNameableNode | BindingNamedNode): string;
34declare type PropertyNameNameableNode<T extends ts.PropertyName> = ts.Node & {
35 readonly propertyName?: T;
36};
37export declare function getPropertyNameNode<T extends ts.PropertyName>(node: PropertyNameNameableNode<T>): T | undefined;
38declare type DotDotDotTokenNode = ts.Node & {
39 readonly dotDotDotToken?: ts.DotDotDotToken;
40};
41export declare function getDotDotDotToken(node: DotDotDotTokenNode): ts.DotDotDotToken | undefined;
42export declare function getText(node: ts.Node): string;
43export declare function getParentSyntaxList(node: ts.Node): ts.Node | undefined;
44export declare function getParent<TNode extends ts.Node>(node: TNode): TNode extends {
45 readonly parent?: infer TParent | null;
46} ? TParent : never;
47export declare function getAncestors(node: ts.Node): IterableIterator<ts.Node>;
48export declare function getDescendants(node: ts.Node): IterableIterator<ts.Node>;
49export declare function getDescendantsByKind<TNode extends ts.Node>(node: ts.Node, kind: TNode extends {
50 readonly kind: infer TKind;
51} ? TKind : never): IterableIterator<TNode>;
52export declare function getSymbol(typeChecker: ts.TypeChecker, node: ts.Node): ts.Symbol | undefined;
53export declare function getSymbolOrThrow(typeChecker: ts.TypeChecker, node: ts.Node): ts.Symbol;
54export declare function getFirstChild(node: ts.Node): ts.Node | undefined;
55export declare function getFirstChildByKind<TNode extends ts.Node>(node: ts.Node, kind: TNode extends {
56 readonly kind: infer TKind;
57} ? TKind : never): TNode | undefined;
58export declare function getFirstAncestorByKind<TNode extends ts.Node>(node: ts.Node, kind: TNode extends {
59 readonly kind: infer TKind;
60} ? TKind : never): TNode | undefined;
61export declare function getFirstAncestorByKindOrThrow<TNode extends ts.Node>(node: ts.Node, kind: TNode extends {
62 readonly kind: infer TKind;
63} ? TKind : never): TNode;
64export declare function getFirstAncestorByTest<TNode extends ts.Node>(node: ts.Node, isNode: (value: ts.Node) => value is TNode): TNode | undefined;
65export declare function getFirstAncestorByTestOrThrow<TNode extends ts.Node>(node: ts.Node, isNode: (value: ts.Node) => value is TNode): TNode;
66export declare function getFirstDescendantByKind<TNode extends ts.Node>(node: ts.Node, kind: TNode extends {
67 readonly kind: infer TKind;
68} ? TKind : never): TNode | undefined;
69export declare function isGlobalAugmentation(node: ts.Node): boolean;
70export declare function getSourceFile(node: ts.Node): ts.SourceFile;
71export declare function getPos(node: ts.Node): number;
72export declare function getEnd(node: ts.Node): number;
73export declare function getChildAtPos(node: ts.Node, pos: number): ts.Node | undefined;
74export declare function getDescendantAtPos(nodeIn: ts.Node, pos: number): ts.Node | undefined;
75export declare function isPartOfTypeNode(node: ts.Node): boolean;
76export {};