1 | import * as ts from 'typescript';
|
2 | import { Emitter } from './emitter';
|
3 | import { ProjectInfo } from './project-info';
|
4 |
|
5 |
|
6 |
|
7 | export declare class Assembler implements Emitter {
|
8 | readonly projectInfo: ProjectInfo;
|
9 | private readonly system;
|
10 | readonly program: ts.Program;
|
11 | readonly stdlib: string;
|
12 | private readonly runtimeTypeInfoInjector;
|
13 | private readonly deprecatedRemover?;
|
14 | private readonly warningsInjector?;
|
15 | private readonly mainFile;
|
16 | private readonly tscRootDir?;
|
17 | private readonly compressAssembly?;
|
18 | private readonly _typeChecker;
|
19 | private _diagnostics;
|
20 | private _deferred;
|
21 | private readonly _types;
|
22 | private readonly _packageInfoCache;
|
23 |
|
24 | private readonly _submoduleMap;
|
25 | |
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | private readonly _submodules;
|
34 | |
35 |
|
36 |
|
37 |
|
38 |
|
39 | constructor(projectInfo: ProjectInfo, system: ts.System, program: ts.Program, stdlib: string, options?: AssemblerOptions);
|
40 | get customTransformers(): ts.CustomTransformers;
|
41 | /**
|
42 | * Attempt emitting the JSII assembly for the program.
|
43 | *
|
44 | * @return the result of the assembly emission.
|
45 | */
|
46 | emit(): ts.EmitResult;
|
47 | private _afterEmit;
|
48 | /**
|
49 | * Defer a callback until a (set of) types are available
|
50 | *
|
51 | * This is a helper function around _defer() which encapsulates the _dereference
|
52 | * action (which is basically the majority use case for _defer anyway).
|
53 | *
|
54 | * Will not invoke the function with any 'undefined's; an error will already have been emitted in
|
55 | * that case anyway.
|
56 | *
|
57 | * @param fqn FQN of the current type (the type that has a dependency on baseTypes)
|
58 | * @param baseTypes Array of type references to be looked up
|
59 | * @param referencingNode Node to report a diagnostic on if we fail to look up a t ype
|
60 | * @param cb Callback to be invoked with the Types corresponding to the TypeReferences in baseTypes
|
61 | */
|
62 | private _deferUntilTypesAvailable;
|
63 | /**
|
64 | * Defer checks for after the program has been entirely processed; useful for verifying type references that may not
|
65 | * have been discovered yet, and verifying properties about them.
|
66 | *
|
67 | * The callback is guaranteed to be executed only after all deferreds for all types in 'dependedFqns' have
|
68 | * been executed.
|
69 | *
|
70 | * @param fqn FQN of the current type.
|
71 | * @param dependedFqns List of FQNs of types this callback depends on. All deferreds for all
|
72 | * @param cb the function to be called in a deferred way. It will be bound with ``this``, so it can depend on using
|
73 | * ``this``.
|
74 | */
|
75 | private _defer;
|
76 | /**
|
77 | * Obtains the ``spec.Type`` for a given ``spec.NamedTypeReference``.
|
78 | *
|
79 | * @param ref the type reference to be de-referenced
|
80 | *
|
81 | * @returns the de-referenced type, if it was found, otherwise ``undefined``.
|
82 | */
|
83 | private _dereference;
|
84 | /**
|
85 | * Compute the JSII fully qualified name corresponding to a ``ts.Type`` instance. If for any reason a name cannot be
|
86 | * computed for the type, a marker is returned instead, and an ``ts.DiagnosticCategory.Error`` diagnostic is
|
87 | * inserted in the assembler context.
|
88 | *
|
89 | * @param type the type for which a JSII fully qualified name is needed.
|
90 | * @param typeAnnotationNode the type annotation for which this FQN is generated. This is used for attaching the error
|
91 | * marker. When there is no explicit type annotation (e.g: inferred method return type), the
|
92 | * preferred substitute is the "type-inferred" element's name.
|
93 | * @param typeUse the reason why this type was resolved (e.g: "return type")
|
94 | * @param isThisType whether this type was specified or inferred as "this" or not
|
95 | *
|
96 | * @returns the FQN of the type, or some "unknown" marker.
|
97 | */
|
98 | private _getFQN;
|
99 | /**
|
100 | * For all modules in the dependency closure, crawl their exports to register
|
101 | * the submodules they contain.
|
102 | *
|
103 | * @param entryPoint the main source file for the currently compiled module.
|
104 | */
|
105 | private _registerDependenciesNamespaces;
|
106 | private _registerNamespaces;
|
107 | /**
|
108 | * Registers Symbols to a particular submodule. This is used to associate
|
109 | * declarations exported by an `export * as ns from 'moduleLike';` statement
|
110 | * so that they can subsequently be correctly namespaced.
|
111 | *
|
112 | * @param ns the symbol that identifies the submodule.
|
113 | * @param moduleLike the module-like symbol bound to the submodule.
|
114 | * @param packageRoot the root of the package being traversed.
|
115 | */
|
116 | private _addToSubmodule;
|
117 | /**
|
118 | * Register exported types in ``this.types``.
|
119 | *
|
120 | * @param node a node found in a module
|
121 | * @param namePrefix the prefix for the types' namespaces
|
122 | */
|
123 | private _visitNode;
|
124 | private getSymbolId;
|
125 | private _validateHeritageClauses;
|
126 | private declarationLocation;
|
127 | private _processBaseInterfaces;
|
128 | private _visitClass;
|
129 | /**
|
130 | * Use the TypeChecker's getTypeFromTypeNode, but throw a descriptive error if it fails
|
131 | */
|
132 | private _getTypeFromTypeNode;
|
133 | /**
|
134 | * Check that this class doesn't declare any members that are of different staticness in itself or any of its bases
|
135 | */
|
136 | private _verifyNoStaticMixing;
|
137 | /**
|
138 | * Wrapper around _deferUntilTypesAvailable, invoke the callback with the given classes' base type
|
139 | *
|
140 | * Does nothing if the given class doesn't have a base class.
|
141 | *
|
142 | * The second argument will be a `recurse` function for easy recursion up the inheritance tree
|
143 | * (no messing around with binding 'self' and 'this' and doing multiple calls to _withBaseClass.)
|
144 | */
|
145 | private _withBaseClass;
|
146 | /**
|
147 | * @returns true if this member is internal and should be omitted from the type manifest
|
148 | */
|
149 | private _isPrivateOrInternal;
|
150 | private _visitEnum;
|
151 | private assertNoDuplicateEnumValues;
|
152 | /**
|
153 | * Return docs for a symbol
|
154 | */
|
155 | private _visitDocumentation;
|
156 | /**
|
157 | * Check that all parameters the doc block refers to with a @param declaration actually exist
|
158 | */
|
159 | private _validateReferencedDocParams;
|
160 | private _visitInterface;
|
161 | private _visitMethod;
|
162 | private _warnAboutReservedWords;
|
163 | private _visitProperty;
|
164 | private _toParameter;
|
165 | private _typeReference;
|
166 | private _optionalValue;
|
167 | private callDeferredsInOrder;
|
168 | /**
|
169 | * Return the set of all (inherited) properties of an interface
|
170 | */
|
171 | private allProperties;
|
172 | private _verifyConsecutiveOptionals;
|
173 | /**
|
174 | * Updates the runtime type info with the fully-qualified name for the current class definition.
|
175 | * Used by the runtime type info injector to add this information to the compiled file.
|
176 | */
|
177 | private registerExportedClassFqn;
|
178 | /**
|
179 | * Return only those submodules from the submodules list that are submodules inside this
|
180 | * assembly.
|
181 | */
|
182 | private mySubmodules;
|
183 | private findPackageInfo;
|
184 | }
|
185 | export interface AssemblerOptions {
|
186 | |
187 |
|
188 |
|
189 |
|
190 |
|
191 | readonly stripDeprecated?: boolean;
|
192 | |
193 |
|
194 |
|
195 |
|
196 |
|
197 |
|
198 |
|
199 | readonly stripDeprecatedAllowListFile?: string;
|
200 | |
201 |
|
202 |
|
203 |
|
204 |
|
205 | readonly addDeprecationWarnings?: boolean;
|
206 | |
207 |
|
208 |
|
209 |
|
210 |
|
211 | readonly compressAssembly?: boolean;
|
212 | }
|
213 |
|
\ | No newline at end of file |