UNPKG

3.08 kBTypeScriptView Raw
1import { ReflectorReader } from './private_import_core';
2/**
3 * The host of the static resolver is expected to be able to provide module metadata in the form of
4 * ModuleMetadata. Angular 2 CLI will produce this metadata for a module whenever a .d.ts files is
5 * produced and the module has exported variables or classes with decorators. Module metadata can
6 * also be produced directly from TypeScript sources by using MetadataCollector in tools/metadata.
7 */
8export interface StaticReflectorHost {
9 /**
10 * Return a ModuleMetadata for the given module.
11 *
12 * @param modulePath is a string identifier for a module as an absolute path.
13 * @returns the metadata for the given module.
14 */
15 getMetadataFor(modulePath: string): {
16 [key: string]: any;
17 } | {
18 [key: string]: any;
19 }[];
20 /**
21 * Resolve a symbol from an import statement form, to the file where it is declared.
22 * @param module the location imported from
23 * @param containingFile for relative imports, the path of the file containing the import
24 */
25 findDeclaration(modulePath: string, symbolName: string, containingFile?: string): StaticSymbol;
26 getStaticSymbol(declarationFile: string, name: string, members?: string[]): StaticSymbol;
27 angularImportLocations(): {
28 coreDecorators: string;
29 diDecorators: string;
30 diMetadata: string;
31 diOpaqueToken: string;
32 animationMetadata: string;
33 provider: string;
34 };
35 getCanonicalFileName(fileName: string): string;
36}
37/**
38 * A token representing the a reference to a static type.
39 *
40 * This token is unique for a filePath and name and can be used as a hash table key.
41 */
42export declare class StaticSymbol {
43 filePath: string;
44 name: string;
45 members: string[];
46 constructor(filePath: string, name: string, members?: string[]);
47}
48/**
49 * A static reflector implements enough of the Reflector API that is necessary to compile
50 * templates statically.
51 */
52export declare class StaticReflector implements ReflectorReader {
53 private host;
54 private annotationCache;
55 private propertyCache;
56 private parameterCache;
57 private metadataCache;
58 private conversionMap;
59 private opaqueToken;
60 constructor(host: StaticReflectorHost);
61 importUri(typeOrFunc: StaticSymbol): string;
62 resolveIdentifier(name: string, moduleUrl: string, runtime: any): any;
63 resolveEnum(enumIdentifier: any, name: string): any;
64 annotations(type: StaticSymbol): any[];
65 propMetadata(type: StaticSymbol): {
66 [key: string]: any;
67 };
68 parameters(type: StaticSymbol): any[];
69 hasLifecycleHook(type: any, lcProperty: string): boolean;
70 private registerDecoratorOrConstructor(type, ctor);
71 private registerFunction(type, fn);
72 private initializeConversionMap();
73 /** @internal */
74 simplify(context: StaticSymbol, value: any): any;
75 /**
76 * @param module an absolute path to a module file.
77 */
78 getModuleMetadata(module: string): {
79 [key: string]: any;
80 };
81 private getTypeMetadata(type);
82}