UNPKG

2.84 kBTypeScriptView Raw
1import * as ts from 'typescript';
2import { Change } from './change';
3import { Observable } from 'rxjs/Observable';
4import 'rxjs/add/observable/empty';
5import 'rxjs/add/observable/of';
6import 'rxjs/add/operator/do';
7import 'rxjs/add/operator/filter';
8import 'rxjs/add/operator/last';
9import 'rxjs/add/operator/map';
10import 'rxjs/add/operator/mergeMap';
11import 'rxjs/add/operator/toArray';
12import 'rxjs/add/operator/toPromise';
13/**
14* Get TS source file based on path.
15* @param filePath
16* @return source file of ts.SourceFile kind
17*/
18export declare function getSource(filePath: string): ts.SourceFile;
19/**
20 * Get all the nodes from a source, as an observable.
21 * @param sourceFile The source file object.
22 * @returns {Observable<ts.Node>} An observable of all the nodes in the source.
23 */
24export declare function getSourceNodes(sourceFile: ts.SourceFile): Observable<ts.Node>;
25/**
26 * Insert `toInsert` after the last occurence of `ts.SyntaxKind[nodes[i].kind]`
27 * or after the last of occurence of `syntaxKind` if the last occurence is a sub child
28 * of ts.SyntaxKind[nodes[i].kind] and save the changes in file.
29 *
30 * @param nodes insert after the last occurence of nodes
31 * @param toInsert string to insert
32 * @param file file to insert changes into
33 * @param fallbackPos position to insert if toInsert happens to be the first occurence
34 * @param syntaxKind the ts.SyntaxKind of the subchildren to insert after
35 * @return Change instance
36 * @throw Error if toInsert is first occurence but fall back is not set
37 */
38export declare function insertAfterLastOccurrence(nodes: ts.Node[], toInsert: string, file: string, fallbackPos?: number, syntaxKind?: ts.SyntaxKind): Change;
39export declare function getContentOfKeyLiteral(source: ts.SourceFile, node: ts.Node): string;
40export declare function getDecoratorMetadata(source: ts.SourceFile, identifier: string, module: string): Observable<ts.Node>;
41/**
42* Custom function to insert a declaration (component, pipe, directive)
43* into NgModule declarations. It also imports the component.
44*/
45export declare function addDeclarationToModule(modulePath: string, classifiedName: string, importPath: string): Promise<Change>;
46/**
47 * Custom function to insert a declaration (component, pipe, directive)
48 * into NgModule declarations. It also imports the component.
49 */
50export declare function addImportToModule(modulePath: string, classifiedName: string, importPath: string): Promise<Change>;
51/**
52 * Custom function to insert a provider into NgModule. It also imports it.
53 */
54export declare function addProviderToModule(modulePath: string, classifiedName: string, importPath: string): Promise<Change>;
55/**
56 * Custom function to insert an export into NgModule. It also imports it.
57 */
58export declare function addExportToModule(modulePath: string, classifiedName: string, importPath: string): Promise<Change>;