@nstudio/nativescript-compiler-angular 0.0.0-stage → 9.2.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/kotlin.js ADDED
@@ -0,0 +1,295 @@
1
+ import { core, ts } from "./core-api.js";
2
+ import { ngModuleDef, standaloneImports } from "./ng-modules.js";
3
+ import { KIT_TOKENS, angularCall, forwardRefTarget, injectableRole, injectableShared, injected, isInjectableClass, isLinkedSignalPreviousSource, isStatic, model, parameterDecorators } from "./semantics.js";
4
+ /** An injection token's name: a framework class by the name it is declared with (`NativeDialog` is `NativeDialogService`). */
5
+ function tokenName(t, e) {
6
+ const decl = t.resolve(e)?.declarations?.[0];
7
+ if (!decl || !ts.isClassDeclaration(decl) || !decl.name)
8
+ return e.getText();
9
+ const file = decl.getSourceFile();
10
+ if (file.fileName.startsWith('/__shims__/'))
11
+ return decl.name.text;
12
+ // A program's class by its Kotlin name, whatever the import calls it (`RouterExtensions as $RouterExtensions`).
13
+ return file.isDeclarationFile ? e.getText() : t.topName(decl, decl.name.text);
14
+ }
15
+ /** What `inject(token)` gives at `at`. */
16
+ function injectedToken(t, token, at, decl) {
17
+ const code = injected('kotlin', token, at, decl && ts.isClassDeclaration(decl) ? injectableShared(decl, t.pluginFiles, t.checker) : undefined);
18
+ // A `shared` the module's statements initialize is held nullable until they run, which they have by injection.
19
+ const shared = decl && ts.isClassDeclaration(decl) ? decl.members.find((m) => ts.isPropertyDeclaration(m) && isStatic(m) && m.name.getText() === 'shared') : undefined;
20
+ return shared && t.heldUntilModuleRuns(shared) && code === `${token}.shared` ? `${code}!!` : code;
21
+ }
22
+ /** A class only a library's typings declare has no instance in a release build: the library's JavaScript provides it. */
23
+ function refuseTypingsOnlyToken(t, tokenDecl, token, at) {
24
+ if (tokenDecl && ts.isClassDeclaration(tokenDecl) && tokenDecl.getSourceFile().isDeclarationFile && !core.isCoreDeclaration(tokenDecl))
25
+ throw t.error(at, `an injected class only a library's typings declare (${token})`, 'library-injectable');
26
+ }
27
+ function parameterInject(t, p) {
28
+ const pt = t.typeOf(p.name);
29
+ const { token: given, optional, skipSelf } = parameterDecorators(p);
30
+ if (optional && skipSelf)
31
+ return core.kotlin.isNullable(pt) || pt === 'Any?' ? 'null' : t.fromAny('null', pt);
32
+ const injectArg = given && forwardRefTarget(given);
33
+ if (injectArg) {
34
+ const target = ts.isExpressionWithTypeArguments(injectArg) ? injectArg.expression : injectArg;
35
+ const token = tokenName(t, target);
36
+ if (token === 'NATIVE_DIALOG_DATA')
37
+ return t.fromAny('NativeDialogRef.current.data', pt);
38
+ const tokenDecl = t.resolve(target)?.declarations?.[0];
39
+ if (KIT_TOKENS.includes(token) || isInjectableClass(tokenDecl, t.pluginFiles))
40
+ return injectedToken(t, token, p, tokenDecl);
41
+ refuseTypingsOnlyToken(t, tokenDecl, token, p);
42
+ const raw = `Injector.inject(${t.coerce(injectArg, 'Any?')}${optional ? ', JSObject("optional" to true)' : ''})`;
43
+ return pt === 'Any?' ? raw : t.fromAny(raw, pt);
44
+ }
45
+ const ref = p.type && ts.isTypeReferenceNode(p.type)
46
+ ? p.type
47
+ : p.type && ts.isUnionTypeNode(p.type)
48
+ ? p.type.types.find(ts.isTypeReferenceNode)
49
+ : undefined;
50
+ if (ref) {
51
+ const token = tokenName(t, ref.typeName);
52
+ const tokenDecl = t.resolve(ref.typeName)?.declarations?.[0];
53
+ if (KIT_TOKENS.includes(token) || isInjectableClass(tokenDecl, t.pluginFiles))
54
+ return injectedToken(t, token, p, tokenDecl);
55
+ if (tokenDecl && ts.isClassDeclaration(tokenDecl)) {
56
+ refuseTypingsOnlyToken(t, tokenDecl, token, p);
57
+ const raw = `Injector.inject(${token}::class.java${optional ? ', JSObject("optional" to true)' : ''})`;
58
+ return pt === 'Any?' ? raw : t.fromAny(raw, pt);
59
+ }
60
+ }
61
+ return undefined;
62
+ }
63
+ /** `linkedSignal({ source, computation })`: `computation`'s `previous` is the runtime's pair made the parameter's object. */
64
+ function linkedSignal(t, options, type, equals) {
65
+ const prop = (n) => {
66
+ const p = options.properties.find((q) => q.name && ts.isIdentifier(q.name) && q.name.text === n);
67
+ if (!p)
68
+ return undefined;
69
+ if (ts.isPropertyAssignment(p))
70
+ return p.initializer;
71
+ if (ts.isShorthandPropertyAssignment(p))
72
+ return p.name;
73
+ throw t.error(p, `a \`${n}\` of linkedSignal's options other than a property`);
74
+ };
75
+ const source = prop('source'), computation = prop('computation');
76
+ if (!source || !computation)
77
+ throw t.error(options, 'linkedSignal options without both `source` and `computation`');
78
+ const c = t.checker;
79
+ const sig = c.getResolvedSignature(options.parent);
80
+ const opts = c.getTypeOfSymbol(sig.parameters[0]);
81
+ const s = t.type(c.getTypeOfSymbol(c.getPropertyOfType(opts, 'source')).getCallSignatures()[0].getReturnType(), options);
82
+ const compSig = c.getTypeOfSymbol(c.getPropertyOfType(opts, 'computation')).getCallSignatures()[0];
83
+ const compActual = c.getTypeAtLocation(computation).getCallSignatures()[0];
84
+ const takesPrevious = (compActual?.parameters.length ?? 2) > 1;
85
+ const prevParam = takesPrevious ? (compActual?.parameters[1] ?? compSig.parameters[1]) : undefined;
86
+ const prevObj = prevParam ? c.getNonNullableType(c.getTypeOfSymbol(prevParam)) : undefined;
87
+ const prevType = prevObj ? t.type(prevObj, options) : undefined;
88
+ const sourceProp = prevObj?.getProperty('source');
89
+ const sourceDecl = sourceProp?.valueDeclaration ?? sourceProp?.declarations?.[0];
90
+ const sourceOpt = !!(sourceProp && (sourceProp.flags & ts.SymbolFlags.Optional)) || (!!sourceDecl && (ts.isPropertySignature(sourceDecl) || ts.isPropertyDeclaration(sourceDecl)) && isLinkedSignalPreviousSource(sourceDecl, c)) || s.endsWith('?');
91
+ const sOpt = s.endsWith('?') ? s : `${s}?`;
92
+ const read = t.typeOf(source).startsWith('Signal<') ? `{ ${t.expr(source)}.value }` : t.symbolName(source) === 'Signal' ? `{ ${t.expr(source)} }` : t.expr(source);
93
+ const made = prevType && /^Object_\w+$/.test(prevType)
94
+ ? sourceOpt
95
+ ? `${prevType}(source = it.first, value = it.second)`
96
+ : t.fromAny('JSObject("source" to it.first, "value" to it.second)', prevType)
97
+ : 'JSObject("source" to it.first, "value" to it.second)';
98
+ return `Signal.linked<${s}, ${type}>(${read}, { s: ${s}, p: Pair<${sOpt}, ${type}>? -> (${t.expr(computation)})(s${prevType ? `, p?.let { ${made} }` : ''}) }${equals})`;
99
+ }
100
+ /** Whether a `linkedSignal(…)` call resolves to the overload taking `{ source, computation }` rather than a function. */
101
+ function linkedOptionsOverload(t, e) {
102
+ const first = t.checker.getResolvedSignature(e)?.parameters[0];
103
+ return !!first && t.checker.getTypeOfSymbol(first).getCallSignatures().length === 0;
104
+ }
105
+ /**
106
+ * `linkedSignal(options)` with options other than a literal: `source`, `computation` and `equal` read by name once, as
107
+ * the signal is made, as Angular reads them. `previous` is made the type the options' own `computation` declares, which
108
+ * is what the function held there takes.
109
+ */
110
+ function linkedSignalOptions(t, options, type, reference) {
111
+ const c = t.checker;
112
+ const sig = c.getResolvedSignature(options.parent);
113
+ const opts = c.getTypeOfSymbol(sig.parameters[0]);
114
+ const s = t.type(c.getTypeOfSymbol(c.getPropertyOfType(opts, 'source')).getCallSignatures()[0].getReturnType(), options);
115
+ const held = c.getPropertyOfType(c.getNonNullableType(c.getTypeAtLocation(options)), 'computation');
116
+ const prevParam = held && c.getNonNullableType(c.getTypeOfSymbol(held)).getCallSignatures()[0]?.parameters[1];
117
+ const prevType = prevParam ? t.type(c.getNonNullableType(c.getTypeOfSymbol(prevParam)), options) : 'Any?';
118
+ const previous = t.fromAny('JSObject("source" to it.first, "value" to it.second)', prevType);
119
+ const sOpt = s.endsWith('?') ? s : `${s}?`;
120
+ const fallback = reference ? '::jsSame' : `{ a: ${type}, b: ${type} -> a == b }`;
121
+ return `run { val __o: Any? = ${t.coerce(options, 'Any?')}; val __source = jsGetOptional(__o, "source"); val __computation = jsGetOptional(__o, "computation"); `
122
+ + `Signal.linked<${s}, ${type}>({ ${t.fromAny('jsCall(__source)', s)} }, { s: ${s}, p: Pair<${sOpt}, ${type}>? -> ${t.fromAny(`jsCall(__computation, s, p?.let { ${previous} })`, type)} }, jsEqualOption<${type}>(__o, ${fallback})) }`;
123
+ }
124
+ function globalCall(t, name, e, decl, lib) {
125
+ const arg = (k) => e.arguments[k];
126
+ if (name === 'linkedSignal' && lib) {
127
+ const type = t.typeOf(e).replace(/^Signal<(.*)>$/, '$1');
128
+ const reference = !['Double', 'String', 'Boolean'].includes(type.replace(/\?$/, '')) && !core.kotlin.isFunctionType(type);
129
+ const fallback = reference ? ', ::jsSame' : '';
130
+ const options = arg(0) && ts.isObjectLiteralExpression(ts.skipOuterExpressions(arg(0))) ? ts.skipOuterExpressions(arg(0)) : undefined;
131
+ if (!options && linkedOptionsOverload(t, e))
132
+ return linkedSignalOptions(t, arg(0), type, reference);
133
+ if (!options)
134
+ return `Signal.linked<${type}>(${t.expr(arg(0))}${t.equalsArg(arg(1), type) ?? fallback})`;
135
+ return linkedSignal(t, options, type, t.equalsArg(options, type) ?? fallback);
136
+ }
137
+ if (name === 'computed' && angularCall(e, 'computed', t.checker) && t.typeOf(e).startsWith('Signal<')) {
138
+ const fn = arg(0), rt = t.typeOf(e).replace(/^Signal<(.*)>$/, '$1');
139
+ if (ts.isArrowFunction(fn) || ts.isFunctionExpression(fn))
140
+ return `Signal.computed(${t.memo(fn, rt, t.indent)})`;
141
+ return `Signal.computed(Memo<${rt}>(${t.coerce(fn, `() -> ${rt}`)}${t.equalsArg(arg(1), rt) ?? ''}))`;
142
+ }
143
+ if (name === 'untracked' && lib)
144
+ return `untrack(${t.expr(arg(0))})`;
145
+ if (name === 'runInInjectionContext' && lib) {
146
+ const fn = arg(1);
147
+ if (fn && (ts.isArrowFunction(fn) || ts.isFunctionExpression(fn))) {
148
+ const type = t.typeOf(e);
149
+ return `Injector.runInContext(${t.restArgument(e, arg(0), 'Any?')}, ${t.closure(fn, `() -> ${type}`)})`;
150
+ }
151
+ const raw = `Injector.runInContext(${t.restArgument(e, arg(0), 'Any?')}) { jsCall(${t.restArgument(e, arg(1), 'Any?')}) }`;
152
+ const type = t.typeOf(e);
153
+ return type === 'Any?' || type === 'Unit' ? raw : t.fromAny(raw, type);
154
+ }
155
+ if ((name === 'forwardRef' || name === 'resolveForwardRef') && lib) {
156
+ const fn = arg(0);
157
+ if (fn && (ts.isArrowFunction(fn) || ts.isFunctionExpression(fn)) && !ts.isBlock(fn.body))
158
+ return t.expr(fn.body);
159
+ return `resolveForwardRef(${arg(0) ? t.restArgument(e, arg(0), 'Any?') : 'null'})`;
160
+ }
161
+ if (name === 'isDevMode' && lib)
162
+ return 'false';
163
+ const shimmed = decl && ts.isFunctionDeclaration(decl) && decl.getSourceFile().fileName.startsWith('/__shims__/') ? decl.name?.text : undefined;
164
+ if (shimmed === 'enableProdMode')
165
+ return 'Unit';
166
+ if (shimmed === 'isAngularHmrRestoringRoute')
167
+ return 'false';
168
+ if (name === 'effect' && lib && arg(0))
169
+ return `Effect.deferred(${t.callback(arg(0))})`;
170
+ if (name === 'output' && lib)
171
+ return `${t.typeOf(e)}()`;
172
+ if (name === 'inject' && lib) {
173
+ const rawArg0 = forwardRefTarget(arg(0));
174
+ const target = ts.isExpressionWithTypeArguments(rawArg0) ? rawArg0.expression : rawArg0;
175
+ const token = tokenName(t, target);
176
+ if (token === 'NATIVE_DIALOG_DATA')
177
+ return t.fromAny('NativeDialogRef.current.data', t.typeOf(e));
178
+ const tokenDecl = t.resolve(target)?.declarations?.[0];
179
+ if (KIT_TOKENS.includes(token) || isInjectableClass(tokenDecl, t.pluginFiles))
180
+ return injectedToken(t, token, e, tokenDecl);
181
+ refuseTypingsOnlyToken(t, tokenDecl, token, e);
182
+ const raw = `Injector.inject(${t.coerce(rawArg0, 'Any?')}${arg(1) ? `, ${t.restArgument(e, arg(1), 'Any?')}` : ''})`;
183
+ const type = t.typeOf(e);
184
+ return type === 'Any?' ? raw : t.fromAny(raw, type);
185
+ }
186
+ if (name === 'firstValueFrom' && lib)
187
+ return `rxFirstValueFrom(${t.expr(arg(0))})`;
188
+ if (name === 'registerElement' && (lib || core.adapterRuntimeFile(decl?.getSourceFile().fileName) === 'runtime/angular-rx.ts')) {
189
+ return e.arguments.length >= 3 && arg(2)
190
+ ? `kitRegisterViewMeta(${t.str(arg(0))}, ${t.coerce(arg(1), 'Any?')}, ${t.coerce(arg(2), 'Any?')})`
191
+ : 'Unit';
192
+ }
193
+ return undefined;
194
+ }
195
+ function methodCall(t, owner, method, e) {
196
+ const target = e.expression.expression;
197
+ if ((owner === 'OutputEmitterRef' || owner === 'EventEmitter') && (method === 'emit' || method === 'next')) {
198
+ const value = /^(?:OutputEmitterRef|EventEmitter|Emitter)<(.*)>[?!]?$/.exec(t.typeOf(target))?.[1];
199
+ const a = e.arguments[0];
200
+ return `${t.expr(target)}.emit(${a ? (value && value !== 'Void' && value !== 'Unit' ? t.coerce(a, value) : t.expr(a)) : ''})`;
201
+ }
202
+ if (owner === 'Injector' && method === 'get' && e.arguments[0]) {
203
+ const rawArg0 = forwardRefTarget(e.arguments[0]);
204
+ const raw = `${t.expr(target)}.get(${t.coerce(rawArg0, 'Any?')}${e.arguments[1] ? `, ${t.coerce(e.arguments[1], 'Any?')}` : ''}${e.arguments[2] ? `, ${t.coerce(e.arguments[2], 'Any?')}` : ''})`;
205
+ const type = t.typeOf(e);
206
+ return type === 'Any?' ? raw : t.fromAny(raw, type);
207
+ }
208
+ // `http.get<T>(url, options)` / `http.post<T>(url, body, options)`: the parsed body read as T.
209
+ if (owner === 'HttpClient' && ['get', 'delete', 'head', 'options', 'post', 'put', 'patch', 'request'].includes(method) && t.typeOf(e).startsWith('RxObservable<')) {
210
+ const value = /^RxObservable<(.*)>$/.exec(t.typeOf(e))?.[1] ?? 'Any?';
211
+ const call = method === 'request'
212
+ ? `${t.expr(target)}.request(${t.str(e.arguments[0])}, ${e.arguments[1] ? t.str(e.arguments[1]) : '""'}${e.arguments[2] ? `, ${t.coerce(e.arguments[2], 'Any?')}` : ''})`
213
+ : ['post', 'put', 'patch'].includes(method)
214
+ ? `${t.expr(target)}.${method}(${t.str(e.arguments[0])}${e.arguments[1] ? `, ${t.coerce(e.arguments[1], 'Any?')}` : ', null'}${e.arguments[2] ? `, ${t.coerce(e.arguments[2], 'Any?')}` : ''})`
215
+ : `${t.expr(target)}.${method}(${t.str(e.arguments[0])}${e.arguments[1] ? `, ${t.coerce(e.arguments[1], 'Any?')}` : ''})`;
216
+ return value === 'Any?' ? call : `${call}.mapValues { __v: Any? -> ${t.fromAny('__v', value)} }`;
217
+ }
218
+ return undefined;
219
+ }
220
+ export const kotlinHooks = {
221
+ ...model,
222
+ typeMap: {
223
+ OutputEmitterRef: 'Emitter<$0>',
224
+ EventEmitter: 'Emitter<$0>',
225
+ LetSlot: { type: 'LetSlot<$0>', shim: true },
226
+ RouterExtensions: 'Router',
227
+ EnvironmentInjector: { type: 'Injector', shim: true },
228
+ // kit-android's NativeDialogService takes its config as script gives it.
229
+ NativeDialogConfig: { type: 'Any?', shim: true },
230
+ ...Object.fromEntries(['NativeDialogRef', 'NativeDialogService', 'DestroyRef', 'Injector', 'InjectionToken', 'ErrorHandler', 'NgZone', 'HttpClient', 'ChangeDetectorRef', 'PurePipeCache', 'NodeInjector', 'ElementRef', 'SimpleChange',
231
+ 'TeardownHandle', 'NavigationEnd', 'NavigationStart', 'NavigationCancel', 'NavigationError', 'RoutesRecognized', 'ResolveStart', 'ResolveEnd',
232
+ 'HttpParams', 'HttpHeaders', 'HttpResponse', 'HttpErrorResponse', 'HttpRequest', 'HttpContext', 'HttpContextToken',
233
+ 'ParamMap', 'UrlSegment', 'UrlTree', 'DefaultUrlSerializer', 'ActivatedRouteSnapshot',
234
+ 'ViewContainerRef', 'TemplateRef', 'ComponentRef', 'EmbeddedViewRef', 'ApplicationRef', 'Location', 'PendingTasks', 'Renderer2', 'RendererFactory2'].map((n) => [n, { type: n, shim: true }])),
235
+ },
236
+ globalCall,
237
+ methodCall,
238
+ // `deps: [new Inject(TOKEN)]` names the token itself.
239
+ newCall: (t, name, e) => (name === 'Inject' && e.arguments?.[0] && t.resolve(ts.skipParentheses(e.expression))?.declarations?.[0]?.getSourceFile().fileName.startsWith('/__shims__/') ? t.coerce(e.arguments[0], 'Any?') : undefined),
240
+ constructorParameter: parameterInject,
241
+ componentField(t, m, name) {
242
+ const callee = m.initializer ? t.calleeName(m.initializer) : '';
243
+ if (callee === 'input' || callee === 'input.required' || callee === 'model' || callee === 'model.required') {
244
+ const type = t.typeOf(m.name).replace(/^Signal<(.*)>$/, '$1');
245
+ const given = m.initializer.arguments[0];
246
+ return { prop: { type, default: given ? (type.startsWith('JSNullish<') ? t.stored(given, given, type) : t.coerce(given, type)) : callee === 'input' || callee === 'model' ? (type.startsWith('JSNullish<') ? 'JSNullish.Undefined' : 'null') : undefined } };
247
+ }
248
+ if (callee !== 'toSignal')
249
+ return undefined;
250
+ // A signal of the source's latest value, read as a computed is: by its name.
251
+ const ident = core.kotlin.ident;
252
+ const [source, options] = m.initializer.arguments;
253
+ const type = t.typeOf(m.name);
254
+ const initial = options && ts.isObjectLiteralExpression(options) ? options.properties.find((p) => ts.isPropertyAssignment(p) && p.name.getText() === 'initialValue') : undefined;
255
+ // rxjs compiled from source: the program's `toSignal`, a signal of any value, its value read as the field types it.
256
+ const program = t.resolve(m.initializer.expression)?.declarations?.some((d) => !d.getSourceFile().isDeclarationFile);
257
+ if (program)
258
+ return { lines: [` private val __${name}: Signal<Any?> = ${t.fromAny(t.expr(m.initializer), 'Signal<Any?>')}`, ` val ${ident(name)}: ${type}`, ` get() = ${t.fromAny(`__${name}.value`, type)}`] };
259
+ if (!initial)
260
+ throw t.error(m, 'toSignal without an initialValue');
261
+ return { lines: [` private val __${name}: Signal<${type}> = toSignal(${t.expr(source)}, ${t.coerce(initial.initializer, type)})`, ` val ${ident(name)}: ${type}`, ` get() = __${name}.value`] };
262
+ },
263
+ componentStatics(t, cls) {
264
+ const ngImports = standaloneImports(cls, t.checker, t.compiles);
265
+ return ngImports ? [` val jsNgImports: Any? by lazy { jsArrayOf<Any?>(${ngImports.map((e) => t.coerce(e, 'Any?')).join(', ')}) }`] : [];
266
+ },
267
+ componentAsValue: (t, cls, type) => `ComponentFactory(${type}::class.java) { ${t.rootView(cls, type, `AngularView.construct { ${type}() }.${t.components.get(cls.name.text)?.members?.render ?? 'render'}()`)} }`,
268
+ /** A component created as a root view (bootstrap, route, dialog): made and rendered in its standalone injector. */
269
+ wrapRootView: (t, cls, type, make) => (standaloneImports(cls, t.checker, t.compiles) ? `Injector.standalone(${type}::class.java, ${type}.jsNgImports) { ${make} }` : make),
270
+ dynamicImport: (specifier) => specifier === '@angular/compiler' ? 'JSPromise.reject<Any?>(JSError("Dynamic import(\'@angular/compiler\') is not available in AOT release builds"))' : undefined,
271
+ serviceClass(t, cls, name) {
272
+ const { params, lines, statics } = t.componentMembers(cls, [], true);
273
+ return [`class ${name}(${params.join(', ')}) {`, ...lines, '', ' companion object {', ` val shared: ${name} get() = AppInjector.service(${name}::class.java) { ${name}() }`, ...statics, ' }', '}'].join('\n');
274
+ },
275
+ classExtras(t, cls, name) {
276
+ const ident = core.kotlin.ident;
277
+ const members = [];
278
+ const role = injectableRole(cls, t.pluginFiles);
279
+ if (role === 'based' || role === 'root') {
280
+ const ctor = cls.members.find((m) => ts.isConstructorDeclaration(m) && !!m.body);
281
+ const made = `${ident(name)}(${(ctor?.parameters ?? []).map((p) => t.constructorParameter(p)).join(', ')})`;
282
+ members.push(` val ${injectableShared(cls, t.pluginFiles, t.checker)}: ${ident(name)} get() = AppInjector.service(${ident(name)}::class.java) { ${made} }`);
283
+ // The kit makes a class of a no-argument constructor itself; one whose constructor injects needs this.
284
+ if (ctor?.parameters.length)
285
+ members.push(` fun jsConstruct(): Any? = ${made}`);
286
+ }
287
+ // What the injector reads of an NgModule: its metadata, evaluated once as the decorator is, and how it is made.
288
+ const ngModule = ngModuleDef(cls, t.checker, t.compiles);
289
+ if (ngModule) {
290
+ const ctor = cls.members.find((m) => ts.isConstructorDeclaration(m) && !!m.body);
291
+ members.push(` override val jsNgImports: Any? by lazy { jsArrayOf<Any?>(${ngModule.imports.map((e) => t.coerce(e, 'Any?')).join(', ')}) }`, ` override val jsNgProviders: Any? by lazy { ${ngModule.providers ? t.coerce(ngModule.providers, 'Any?') : 'null'} }`, ` override fun jsNgConstruct(): Any? = ${ident(name)}(${(ctor?.parameters ?? []).map((p) => t.constructorParameter(p)).join(', ')})`);
292
+ }
293
+ return { members, companionSupertype: ngModule ? 'JSNgModuleDef' : undefined };
294
+ },
295
+ };