@nstudio/nativescript-compiler 9.2.0-alpha.17 → 9.2.0-alpha.19
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/README.md +3 -0
- package/config.js +1 -0
- package/dist/kotlin/access.js +8 -7
- package/dist/kotlin/arguments.js +6 -0
- package/dist/kotlin/assignment.js +22 -13
- package/dist/kotlin/builtins.js +67 -0
- package/dist/kotlin/calls.js +3 -2
- package/dist/kotlin/class-declaration.js +4 -9
- package/dist/kotlin/class-methods.js +2 -2
- package/dist/kotlin/core-api.js +1 -1
- package/dist/kotlin/declarations.js +1 -1
- package/dist/kotlin/expression-statements.js +13 -1
- package/dist/kotlin/functions.js +1 -0
- package/dist/kotlin/literals.js +4 -8
- package/dist/kotlin/names.js +4 -4
- package/dist/kotlin/native/api.js +1 -1
- package/dist/kotlin/operators.js +25 -25
- package/dist/kotlin/optional-chains.js +1 -1
- package/dist/kotlin/overrides.js +3 -3
- package/dist/kotlin/state-backend.js +6 -2
- package/dist/kotlin/translator.js +1 -1
- package/dist/kotlin/types.js +4 -4
- package/dist/semantics/classes.js +15 -0
- package/dist/semantics/conversion.js +9 -1
- package/dist/semantics/facts.js +1 -1
- package/dist/semantics/lang.js +10 -0
- package/dist/semantics/lower.js +54 -0
- package/dist/semantics/lowering-methods.js +5 -0
- package/dist/semantics/placement.js +9 -3
- package/dist/semantics/runtime.js +1 -0
- package/dist/semantics/signals.js +11 -0
- package/dist/semantics/states/missing.js +7 -0
- package/dist/semantics/tdz.js +54 -15
- package/dist/semantics/throws.js +2 -2
- package/dist/semantics/translator-methods.js +1 -1
- package/dist/swift/access.js +7 -9
- package/dist/swift/arguments.js +14 -9
- package/dist/swift/assignment.js +26 -15
- package/dist/swift/calls.js +13 -5
- package/dist/swift/class-methods.js +2 -1
- package/dist/swift/classes.js +7 -9
- package/dist/swift/components.js +3 -3
- package/dist/swift/control-flow.js +1 -1
- package/dist/swift/conversion.js +5 -2
- package/dist/swift/core-api.js +2 -2
- package/dist/swift/declarations.js +1 -1
- package/dist/swift/expressions.js +6 -2
- package/dist/swift/from-any.js +1 -1
- package/dist/swift/functions.js +5 -6
- package/dist/swift/global-calls.js +1 -1
- package/dist/swift/lenient.js +1 -6
- package/dist/swift/library.js +2 -2
- package/dist/swift/literals.js +8 -3
- package/dist/swift/method-values.js +2 -1
- package/dist/swift/modules.js +3 -3
- package/dist/swift/names.js +7 -7
- package/dist/swift/native/calls.js +10 -4
- package/dist/swift/object-classes.js +84 -1
- package/dist/swift/operators.js +31 -29
- package/dist/swift/placement.js +22 -6
- package/dist/swift/state-backend.js +3 -2
- package/dist/swift/static-calls.js +3 -4
- package/dist/swift/syntax.js +10 -6
- package/dist/swift/translator.js +1 -1
- package/dist/swift/type-facts.js +3 -3
- package/dist/swift/types.js +5 -5
- package/dist/targets/ios/build.js +1 -1
- package/kit-android/generated/kotlin/org/nativescript/kit/__Modules.kt +1 -0
- package/kit-android/generated/kotlin/org/nativescript/kit/__Objects.kt +525 -99
- package/kit-android/generated/kotlin/org/nativescript/kit/accessibility_accessibility_common.kt +2 -2
- package/kit-android/generated/kotlin/org/nativescript/kit/application_application_common.kt +29 -6
- package/kit-android/generated/kotlin/org/nativescript/kit/application_helpers_common.kt +14 -0
- package/kit-android/generated/kotlin/org/nativescript/kit/color_color_utils.kt +3 -3
- package/kit-android/generated/kotlin/org/nativescript/kit/css_mediaquery_index.kt +49 -1
- package/kit-android/generated/kotlin/org/nativescript/kit/data_observable_array_index.kt +0 -8
- package/kit-android/generated/kotlin/org/nativescript/kit/data_observable_index.kt +0 -16
- package/kit-android/generated/kotlin/org/nativescript/kit/data_virtual_array_index.kt +6 -4
- package/kit-android/generated/kotlin/org/nativescript/kit/http_http_request_index.kt +19 -7
- package/kit-android/generated/kotlin/org/nativescript/kit/http_http_request_internal_http_request_internal_common.kt +14 -0
- package/kit-android/generated/kotlin/org/nativescript/kit/http_http_request_internal_index.kt +19 -10
- package/kit-android/generated/kotlin/org/nativescript/kit/matrix_index.kt +17 -29
- package/kit-android/generated/kotlin/org/nativescript/kit/media_query_list_index.kt +144 -22
- package/kit-android/generated/kotlin/org/nativescript/kit/npm_css_what_src_parse.kt +8 -3
- package/kit-android/generated/kotlin/org/nativescript/kit/org.nativescript.NativeScriptLifecycleCallbacks.kt +2 -10
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_builder_index.kt +0 -2
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_bindable_expression_parser.kt +6 -10
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_properties_index.kt +531 -8
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_view_base_index.kt +0 -9
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_weak_event_listener_index.kt +3 -3
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_styling_style_index.kt +19 -0
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_styling_style_properties.kt +5 -2
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_styling_style_scope.kt +232 -174
- package/kit-android/generated/kotlin/org/nativescript/kit/ui_text_view_text_view_common.kt +1 -1
- package/kit-android/generated/kotlin/org/nativescript/kit/utils_android_runtime_version.kt +75 -0
- package/kit-android/generated/manifest.json +21 -18
- package/kit-android/generated/source-lines.json +1 -1
- package/kit-android/src/fromcore/kotlin/org/nativescript/kit/NativeScriptApplication.kt +9 -0
- package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Array.kt +497 -42
- package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Intl.kt +1 -1
- package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/JSON.kt +22 -2
- package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Strings.kt +32 -18
- package/kit-apple/Overlays/xml-free/Core/ui.builder.index.swift +7 -3
- package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity1.swift +14 -10
- package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity2.swift +3 -9
- package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity3Plus.swift +20 -21
- package/kit-apple/Sources/NativeScriptKit/Core/Object_eventName_object_index_section_view_ios_android.swift +5 -7
- package/kit-apple/Sources/NativeScriptKit/Core/Object_eventName_object_ios_android_.swift +130 -0
- package/kit-apple/Sources/NativeScriptKit/Core/Object_eventName_object_oldIndex_newIndex.swift +2 -4
- package/kit-apple/Sources/NativeScriptKit/Core/Object_specified_substituted_reads.swift +115 -0
- package/kit-apple/Sources/NativeScriptKit/Core/Object_substituted_values_reads.swift +113 -0
- package/kit-apple/Sources/NativeScriptKit/Core/Object_substituted_values_reads_.swift +113 -0
- package/kit-apple/Sources/NativeScriptKit/Core/application.application-common.swift +348 -330
- package/kit-apple/Sources/NativeScriptKit/Core/application.application.ios.swift +358 -359
- package/kit-apple/Sources/NativeScriptKit/Core/application.helpers-common.swift +47 -29
- package/kit-apple/Sources/NativeScriptKit/Core/connectivity.index.ios.swift +3 -1
- package/kit-apple/Sources/NativeScriptKit/Core/css-mediaquery.index.swift +95 -53
- package/kit-apple/Sources/NativeScriptKit/Core/css.CSS3Parser.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/css.parser.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/data.observable-array.index.swift +3 -3
- package/kit-apple/Sources/NativeScriptKit/Core/file-system.file-system-access.ios.swift +58 -49
- package/kit-apple/Sources/NativeScriptKit/Core/file-system.index.swift +10 -10
- package/kit-apple/Sources/NativeScriptKit/Core/http.http-request-internal.http-request-internal-common.swift +18 -0
- package/kit-apple/Sources/NativeScriptKit/Core/http.http-request-internal.index.ios.swift +67 -52
- package/kit-apple/Sources/NativeScriptKit/Core/http.index.swift +3 -3
- package/kit-apple/Sources/NativeScriptKit/Core/image-source.index.ios.swift +69 -53
- package/kit-apple/Sources/NativeScriptKit/Core/js-libs.easysax.easysax.swift +4 -22
- package/kit-apple/Sources/NativeScriptKit/Core/kit-index.json +144 -32
- package/kit-apple/Sources/NativeScriptKit/Core/manifest.json +30 -19
- package/kit-apple/Sources/NativeScriptKit/Core/media-query-list.index.swift +190 -78
- package/kit-apple/Sources/NativeScriptKit/Core/native-window.native-window.ios.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/npm.css-what.src.parse.swift +205 -201
- package/kit-apple/Sources/NativeScriptKit/Core/npm.css-what.src.stringify.swift +41 -42
- package/kit-apple/Sources/NativeScriptKit/Core/npm.css-what.src.types.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/trace.index.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.action-bar.index.ios.swift +33 -21
- package/kit-apple/Sources/NativeScriptKit/Core/ui.activity-indicator.index.ios.swift +12 -6
- package/kit-apple/Sources/NativeScriptKit/Core/ui.animation.index.ios.swift +77 -65
- package/kit-apple/Sources/NativeScriptKit/Core/ui.animation.keyframe-animation.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.builder.index.swift +10 -6
- package/kit-apple/Sources/NativeScriptKit/Core/ui.button.index.ios.swift +14 -13
- package/kit-apple/Sources/NativeScriptKit/Core/ui.core.properties.index.swift +1273 -824
- package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view-base.index.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view.index.ios.swift +87 -67
- package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view.view-common.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.date-picker.index.ios.swift +17 -16
- package/kit-apple/Sources/NativeScriptKit/Core/ui.dialogs.index.ios.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.editable-text-base.index.ios.swift +27 -18
- package/kit-apple/Sources/NativeScriptKit/Core/ui.frame.frame-common.swift +2 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.frame.index.ios.swift +6 -6
- package/kit-apple/Sources/NativeScriptKit/Core/ui.html-view.index.ios.swift +9 -9
- package/kit-apple/Sources/NativeScriptKit/Core/ui.image.index.ios.swift +6 -6
- package/kit-apple/Sources/NativeScriptKit/Core/ui.label.index.ios.swift +8 -8
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.flexbox-layout.index.ios.swift +22 -21
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.layout-base.ios.swift +4 -3
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.liquid-glass-container.index.ios.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.liquid-glass.index.ios.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.root-layout.index.ios.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.root-layout.root-layout-common.swift +9 -9
- package/kit-apple/Sources/NativeScriptKit/Core/ui.list-picker.index.ios.swift +9 -6
- package/kit-apple/Sources/NativeScriptKit/Core/ui.list-view.index.ios.swift +38 -20
- package/kit-apple/Sources/NativeScriptKit/Core/ui.page.index.ios.swift +204 -190
- package/kit-apple/Sources/NativeScriptKit/Core/ui.progress.index.ios.swift +12 -10
- package/kit-apple/Sources/NativeScriptKit/Core/ui.repeater.index.swift +2 -6
- package/kit-apple/Sources/NativeScriptKit/Core/ui.scroll-view.index.ios.swift +18 -9
- package/kit-apple/Sources/NativeScriptKit/Core/ui.search-bar.index.ios.swift +28 -18
- package/kit-apple/Sources/NativeScriptKit/Core/ui.segmented-bar.index.ios.swift +19 -12
- package/kit-apple/Sources/NativeScriptKit/Core/ui.slider.index.ios.swift +14 -12
- package/kit-apple/Sources/NativeScriptKit/Core/ui.split-view.index.ios.swift +17 -12
- package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.background.ios.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.clip-path-function.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.css-animation-parser.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.css-selector.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.font-common.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.style-scope.swift +869 -838
- package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.style.index.swift +46 -31
- package/kit-apple/Sources/NativeScriptKit/Core/ui.switch.index.ios.swift +12 -10
- package/kit-apple/Sources/NativeScriptKit/Core/ui.tab-view.index.ios.swift +36 -20
- package/kit-apple/Sources/NativeScriptKit/Core/ui.text-base.formatted-string.swift +3 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.text-base.index.ios.swift +25 -22
- package/kit-apple/Sources/NativeScriptKit/Core/ui.text-base.text-base-common.swift +2 -3
- package/kit-apple/Sources/NativeScriptKit/Core/ui.text-field.index.ios.swift +21 -14
- package/kit-apple/Sources/NativeScriptKit/Core/ui.text-view.index.ios.swift +33 -21
- package/kit-apple/Sources/NativeScriptKit/Core/ui.text-view.text-view-common.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.time-picker.index.ios.swift +22 -18
- package/kit-apple/Sources/NativeScriptKit/Core/ui.transition.index.ios.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.transition.modal-transition.ios.swift +4 -4
- package/kit-apple/Sources/NativeScriptKit/Core/ui.transition.page-transition.ios.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/ui.transition.shared-transition-helper.ios.swift +32 -32
- package/kit-apple/Sources/NativeScriptKit/Core/ui.web-view.index.ios.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Core/ui.web-view.web-view-common.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/utils.android-runtime-version.swift +77 -0
- package/kit-apple/Sources/NativeScriptKit/Core/utils.debug-source.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/utils.index.ios.swift +2 -2
- package/kit-apple/Sources/NativeScriptKit/Core/xhr.index.swift +62 -61
- package/kit-apple/Sources/NativeScriptKit/Runtime/Array.swift +4 -0
- package/kit-apple/Sources/NativeScriptKit/Runtime/Dynamic.swift +2 -0
- package/kit-apple/Sources/NativeScriptKit/Runtime/Interop.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Runtime/Intl.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Runtime/Iterators.swift +1 -1
- package/kit-apple/Sources/NativeScriptKit/Runtime/JSON.swift +280 -9
- package/kit-apple/Sources/NativeScriptKit/Runtime/Lowering.swift +3 -2
- package/kit-apple/Sources/NativeScriptKit/Runtime/Native.swift +2 -1
- package/kit-apple/Sources/NativeScriptKit/Runtime/Prototypes.swift +1 -0
- package/kit-apple/Sources/NativeScriptKit/Runtime/Symbol.swift +1 -0
- package/kit-apple/Sources/NativeScriptKit/Runtime/Values.swift +1 -0
- package/kit-apple/Sources/NativeScriptKit/Runtime/Views.swift +2 -0
- package/package.json +6 -4
|
@@ -145,7 +145,8 @@ export const classMethodsMethods = {
|
|
|
145
145
|
this.chainingLoose = true;
|
|
146
146
|
const rawKey = this.propertyKey(m.name.expression);
|
|
147
147
|
this.chainingLoose = saved;
|
|
148
|
-
const
|
|
148
|
+
const keyThrows = this.throwsInfo.expr(m.name.expression);
|
|
149
|
+
const key = fixedKey(m.name.expression, this.checker) ? (keyThrows ? `(try? ${rawKey})` : rawKey) : this.storedSymbolKey(k, m.name.expression, rawKey);
|
|
149
150
|
symbolMethods.push({ key, method, owner: ident(k.name), params: m.parameters.map((p) => this.paramType(p)), unread: m.parameters.map((p) => this.unreadParameter(m, p)), ret: this.returnTypeOf(m), throws: this.throwsInfo.fn(m) });
|
|
150
151
|
lines.push(' ' + this.memberFunc(m, method));
|
|
151
152
|
return;
|
package/dist/swift/classes.js
CHANGED
|
@@ -8,7 +8,7 @@ import { isLibDeclaration, withoutDefault, isWriteTarget } from "../semantics/as
|
|
|
8
8
|
import { isAsync, isStatic } from "../semantics/throws.js";
|
|
9
9
|
import { isCoreDeclaration, isShimDeclaration } from "../program/core-facts.js";
|
|
10
10
|
import { isNativePropertyDecorator } from "../program/patterns.js";
|
|
11
|
-
import { prototypeDecorated } from "../semantics/classes.js";
|
|
11
|
+
import { prototypeDecorated, prototypeMethodList } from "../semantics/classes.js";
|
|
12
12
|
import { isKit, isUntyped, spelledType } from "../semantics/types.js";
|
|
13
13
|
export const classesMethods = {
|
|
14
14
|
/** A class's memo field (`computed(fn)`): the memo the instance makes when it is first read, and the field reading its value (a throw rethrown to each reader). */
|
|
@@ -346,15 +346,13 @@ export const classesMethods = {
|
|
|
346
346
|
return '';
|
|
347
347
|
const i = this.indent;
|
|
348
348
|
const name = this.className(cls);
|
|
349
|
-
const
|
|
349
|
+
const plugin = this.pluginFiles.has(cls.getSourceFile().fileName);
|
|
350
|
+
const inherited = plugin ? this.classPlan(cls).inherited : null;
|
|
351
|
+
const kitRoot = plugin ? this.kitRootOf(cls) : null;
|
|
350
352
|
const entries = [];
|
|
351
|
-
for (const m of cls
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
const key = m.name.getText().replace(/^['"]|['"]$/g, '');
|
|
355
|
-
if (seen.has(key))
|
|
356
|
-
continue;
|
|
357
|
-
seen.add(key);
|
|
353
|
+
for (const { method: m, key } of prototypeMethodList(cls, {
|
|
354
|
+
skip: (m, key) => isAsync(m) || m.parameters.some((p) => p.dotDotDotToken) || this.readsArguments(m) || (plugin && !inherited.has(key) && !(kitRoot && this.core.kitMember(kitRoot, key)) && !this.facts.isNamed(key)),
|
|
355
|
+
})) {
|
|
358
356
|
const sig = this.emittedSignature(m);
|
|
359
357
|
const args = sig.params.map((p, k) => this.throwingConverts(() => this.presentFromAny(`${RT.jsArg}(__a, ${k})`, p.type, true, true)));
|
|
360
358
|
const call = this.marks.tryIf(this.throwsInfo.fn(m), `__o.${ident(key)}(${args.join(', ')})`);
|
package/dist/swift/components.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import ts from 'typescript';
|
|
3
3
|
import { resultSlot } from "../semantics/placement.js";
|
|
4
4
|
import { capturesThis, escapingParam, ident, isFunctionType, isMethodValue, isOptional, metatype, nullishType, optionalType, swiftString, withoutThenables, RT } from "./syntax.js";
|
|
5
|
-
import { equalOption } from "../semantics/signals.js";
|
|
5
|
+
import { equalOption, isReadonlySignalProperty } from "../semantics/signals.js";
|
|
6
6
|
import { isTemplateMethod } from "../semantics/trust.js";
|
|
7
7
|
import { extendsHeritage, hasModifier, nonSuperStatements } from "../semantics/ast.js";
|
|
8
8
|
import { nullableTypeNode, resultsAreUndefinedElements } from "../semantics/lang.js";
|
|
@@ -356,7 +356,7 @@ export const componentMethods = {
|
|
|
356
356
|
return this.throwsInfo.fn(held.arguments[0]) ? ` var ${name}: ${t} {\n get throws { try ${read} }\n }` : ` var ${name}: ${t} { ${read} }`;
|
|
357
357
|
},
|
|
358
358
|
/** Whether a `Signal<T>` node is lowered as a Swift computed property (`var x: T`) rather than a `Signal<T>` instance. */
|
|
359
|
-
|
|
359
|
+
isSwiftComputedProperty(n) {
|
|
360
360
|
if (ts.isIdentifier(n) && this.moduleComputed(n))
|
|
361
361
|
return true;
|
|
362
362
|
const decl = ts.isIdentifier(n) || ts.isPropertyAccessExpression(n) ? this.resolve(n)?.valueDeclaration : n;
|
|
@@ -368,7 +368,7 @@ export const componentMethods = {
|
|
|
368
368
|
}
|
|
369
369
|
if (ts.isPropertyDeclaration(decl) && ts.isClassDeclaration(decl.parent) && !this.pluginFiles.has(decl.getSourceFile().fileName) && decl.initializer) {
|
|
370
370
|
const callee = this.calleeName(decl.initializer);
|
|
371
|
-
if (
|
|
371
|
+
if (isReadonlySignalProperty(decl, this.checker, this.framework, callee) || (ts.isIdentifier(decl.initializer) && !!this.moduleComputed(decl.initializer)))
|
|
372
372
|
return true;
|
|
373
373
|
}
|
|
374
374
|
return false;
|
|
@@ -160,7 +160,7 @@ export const controlFlowMethods = {
|
|
|
160
160
|
let code;
|
|
161
161
|
const block = s.catchClause ? this.block(s.tryBlock) : '';
|
|
162
162
|
// A catch whose try block cannot throw never runs: the block alone.
|
|
163
|
-
if (s.catchClause && !this.throwsInfo.statements([s.tryBlock])) {
|
|
163
|
+
if (s.catchClause && !this.throwsInfo.statements([s.tryBlock]) && !/\btry\s/.test(block)) {
|
|
164
164
|
this.catchless.add(s.tryBlock);
|
|
165
165
|
code = this.scope(s.tryBlock);
|
|
166
166
|
}
|
package/dist/swift/conversion.js
CHANGED
|
@@ -146,8 +146,11 @@ export const conversionMethods = {
|
|
|
146
146
|
return null;
|
|
147
147
|
// Given to the language's or a platform's API (`list.map(f)`, which rethrows what `f` may throw), which never compares it: as it is.
|
|
148
148
|
if ((ts.isCallExpression(p) || ts.isNewExpression(p)) && p.arguments?.includes(e)) {
|
|
149
|
-
const
|
|
150
|
-
|
|
149
|
+
const sig = this.checker.getResolvedSignature(p);
|
|
150
|
+
const callee = sig?.getDeclaration();
|
|
151
|
+
const paramDecl = sig?.getParameters()[p.arguments.indexOf(e)]?.valueDeclaration;
|
|
152
|
+
const paramType = paramDecl ? this.checker.getTypeAtLocation(paramDecl) : undefined;
|
|
153
|
+
if (callee && callee.getSourceFile().isDeclarationFile && !isCoreDeclaration(callee) && paramType && this.checker.getNonNullableType(paramType).getCallSignatures().length > 0)
|
|
151
154
|
return null;
|
|
152
155
|
}
|
|
153
156
|
return decl;
|
package/dist/swift/core-api.js
CHANGED
|
@@ -513,7 +513,7 @@ export class CoreAPI extends KitTypes {
|
|
|
513
513
|
return m?.kind === 'var' && !!m.throws;
|
|
514
514
|
}
|
|
515
515
|
/** A kit property's value or method's result the kit holds optional, read where core's typings say present. */
|
|
516
|
-
|
|
516
|
+
swiftKitNil(x) {
|
|
517
517
|
try {
|
|
518
518
|
x = ts.skipOuterExpressions(x, ts.OuterExpressionKinds.Parentheses);
|
|
519
519
|
if (ts.isCallExpression(x) && ts.isIdentifier(x.expression)) {
|
|
@@ -548,7 +548,7 @@ export class CoreAPI extends KitTypes {
|
|
|
548
548
|
optionalKitValue(x) {
|
|
549
549
|
while (ts.isParenthesizedExpression(x))
|
|
550
550
|
x = x.expression;
|
|
551
|
-
if (!this.t.lenient && !this.t.library && this.
|
|
551
|
+
if (!this.t.lenient && !this.t.library && this.swiftKitNil(x))
|
|
552
552
|
return true;
|
|
553
553
|
if (ts.isIdentifier(x)) {
|
|
554
554
|
const sym = this.t.resolve(x);
|
|
@@ -258,7 +258,7 @@ export const declarationsMethods = {
|
|
|
258
258
|
if (!js) {
|
|
259
259
|
const value = this.coerce(init, this.typeOf(init));
|
|
260
260
|
// What the kit holds optional though the declarations say present (`getActualSize()`): JavaScript's TypeError destructuring undefined.
|
|
261
|
-
if (ts.isObjectBindingPattern(name) && this.marks.isUnwrap(value) && !this.lenient && this.core.
|
|
261
|
+
if (ts.isObjectBindingPattern(name) && this.marks.isUnwrap(value) && !this.lenient && this.core.swiftKitNil(init))
|
|
262
262
|
return `: ${this.typeOf(init)} = try ${this.required(init, this.marks.unwrapInner(value))}`;
|
|
263
263
|
return `: ${this.typeOf(init)} = ${this.marks.tryBefore(this.tryPrefix(init), value)}`;
|
|
264
264
|
}
|
|
@@ -43,7 +43,7 @@ export const expressionsMethods = {
|
|
|
43
43
|
cond(e, cell) {
|
|
44
44
|
const sub = substitutedExpr(this.subst, e);
|
|
45
45
|
if (sub)
|
|
46
|
-
return this.typeOf(sub.bare) === 'Bool' ? sub.code : `${RT.jsTruthy}(${sub.code})`;
|
|
46
|
+
return this.typeOf(sub.bare) === 'Bool' ? sub.code : `${RT.jsTruthy}(${this.marks.isUnwrap(sub.code) ? this.marks.unwrapInner(sub.code) : sub.code})`;
|
|
47
47
|
if (cell === undefined)
|
|
48
48
|
cell = conditionCell(this.conditions, e);
|
|
49
49
|
const code = this.truthy(cell);
|
|
@@ -148,10 +148,11 @@ export const expressionsMethods = {
|
|
|
148
148
|
const t = this.lenientRef(declared) !== declared ? optionalType(declared) : declared;
|
|
149
149
|
const exprType = this.typeOf(a);
|
|
150
150
|
const rt = isUntyped(spelledType(t)) && !isUntyped(spelledType(exprType)) && exprType !== 'Void' ? exprType : t;
|
|
151
|
+
const retType = this.lenientRef(rt) !== rt ? optionalType(rt) : rt;
|
|
151
152
|
const tp = this.tryPrefix(a);
|
|
152
153
|
const retVal = rt !== t ? this.fromAnyCode(this.expr(a.left), rt, true) : this.expr(a.left);
|
|
153
154
|
const retThrows = tp || /\btry\b/.test(retVal);
|
|
154
|
-
return `({ () ${retThrows ? 'throws ' : ''}-> ${
|
|
155
|
+
return `({ () ${retThrows ? 'throws ' : ''}-> ${retType} in ${tp}${this.binary(a)}; return ${retVal} }())`;
|
|
155
156
|
}
|
|
156
157
|
if (ts.isParenthesizedExpression(e)) {
|
|
157
158
|
const inner = this.expr(e.expression);
|
|
@@ -271,6 +272,9 @@ export const expressionsMethods = {
|
|
|
271
272
|
const raw = this.untypedMemberValue(e.expression);
|
|
272
273
|
if (raw)
|
|
273
274
|
return raw;
|
|
275
|
+
const maybe = this.maybeUndefined(e.expression);
|
|
276
|
+
if (maybe)
|
|
277
|
+
return this.marks.leading(`(${maybe} as Any?)`, maybe);
|
|
274
278
|
}
|
|
275
279
|
// `<Array<View>>views` of a ViewBase[]: Swift's arrays of the two are distinct types, so the elements are read as the asserted one, in a copy unless the array already is one.
|
|
276
280
|
const fromArray = /^JSArray<(.+)>[?!]?$/.exec(from), toArray = /^JSArray<(.+)>[?!]?$/.exec(to);
|
package/dist/swift/from-any.js
CHANGED
|
@@ -263,7 +263,7 @@ export const fromAnyMethods = {
|
|
|
263
263
|
// An interface classes implement: an object conforming to it as it is, any other read by its keys.
|
|
264
264
|
return type.endsWith('?') ? `${RT.jsUnlessNullish}(${code}, { (${RT.jsFlat}($0) as? ${base}) ?? ${base}Object(jsObject: $0) })` : `{ (__o: Any?) -> ${base} in (${RT.jsFlat}(__o) as? ${base}) ?? ${base}Object(jsObject: __o) }(${code})`;
|
|
265
265
|
}
|
|
266
|
-
if (this.facts.hasInterface(this, this.interfaces, (d, s) => this.topName(d, s), base) || !!this.shapes.named(base) || (!this.library && this.core.viewable(base))) {
|
|
266
|
+
if ((!this.classNamed(base) && (this.facts.hasInterface(this, this.interfaces, (d, s) => this.topName(d, s), base) || !!this.shapes.named(base))) || (!this.library && this.core.viewable(base))) {
|
|
267
267
|
this.used.add(base);
|
|
268
268
|
// An object of the interface's class already is the object read (a receiver `call` passes); any other is read by its keys.
|
|
269
269
|
return type.endsWith('?') ? `${RT.jsUnlessNullish}(${code}, { (${RT.jsFlat}($0) as? ${base}) ?? ${this.viewOf(base, '$0')} })` : `{ (__o: Any?) -> ${base} in (${RT.jsFlat}(__o) as? ${base}) ?? ${this.viewOf(base, '__o')} }(${code})`;
|
package/dist/swift/functions.js
CHANGED
|
@@ -8,7 +8,7 @@ import { returnCell } from "../semantics/placement.js";
|
|
|
8
8
|
import { hasModifier, isLibDeclaration, withoutDefault, implementationOf, declaresThis } from "../semantics/ast.js";
|
|
9
9
|
import { isAsync, isStatic } from "../semantics/throws.js";
|
|
10
10
|
import { isCoreDeclaration } from "../program/core-facts.js";
|
|
11
|
-
import { methodValues } from "../semantics/lang.js";
|
|
11
|
+
import { builtinConstructorSlot, methodValues } from "../semantics/lang.js";
|
|
12
12
|
import { baseMethod } from "../semantics/classes.js";
|
|
13
13
|
import { isUntyped, spelledType } from "../semantics/types.js";
|
|
14
14
|
export const functionsMethods = {
|
|
@@ -261,11 +261,9 @@ export const functionsMethods = {
|
|
|
261
261
|
const conversion = { Number: [RT.jsToNumber, 'Double'], String: [RT.jsToString, 'String'], Boolean: [RT.jsTruthy, 'Bool'] }[e.text];
|
|
262
262
|
if (!conversion)
|
|
263
263
|
return null;
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
if (!slot)
|
|
268
|
-
return `js${e.text}Constructor`;
|
|
264
|
+
const { singleton, slot } = builtinConstructorSlot(e, this.checker, (c) => isUntyped(spelledType(this.type(c, e))));
|
|
265
|
+
if (singleton)
|
|
266
|
+
return singleton;
|
|
269
267
|
const param = slot?.getParameters()[0];
|
|
270
268
|
const t = param ? this.type(this.checker.getTypeOfSymbolAtLocation(param, e), e) : 'Any?';
|
|
271
269
|
const call = p && ts.isCallExpression(p) && p.arguments[0] === e && ts.isPropertyAccessExpression(p.expression) ? p.expression.expression : null;
|
|
@@ -390,6 +388,7 @@ export const functionsMethods = {
|
|
|
390
388
|
const throws = !isAsync(fn) && this.throwsInfo.fn(fn) ? 'throws ' : '';
|
|
391
389
|
// A function expression's name is only for itself: one that never refers to itself is an anonymous function.
|
|
392
390
|
if (fn.name && refersTo(fn.body, this.checker.getSymbolAtLocation(fn.name), this.checker)) {
|
|
391
|
+
this.refuseNamedGenerator(fn);
|
|
393
392
|
const fnName = ident(fn.name.text);
|
|
394
393
|
const extra = this.unusedParameters(fn).map((t, k) => `_ __unused${k}: ${t}`);
|
|
395
394
|
const fnParams = [this.params(fn, false), ...extra, ...pad.map((p) => (p.startsWith('_ ') ? p : `_ ${p}`))].filter(Boolean).join(', ');
|
|
@@ -161,7 +161,7 @@ export const globalCallsMethods = {
|
|
|
161
161
|
const declared = this.checker.getResolvedSignature(e)?.getDeclaration();
|
|
162
162
|
const isFunctionValue = !declared || ts.isJSDocSignature(declared) || !('body' in declared && declared.body) || ts.isArrowFunction(declared) || ts.isFunctionExpression(declared);
|
|
163
163
|
// A function held untyped (one of several function types): called as script calls it.
|
|
164
|
-
if (this.isAny(callee)) {
|
|
164
|
+
if (this.isAny(callee) && !(declared && ts.isFunctionDeclaration(declared) && declared.body)) {
|
|
165
165
|
const code = `${RT.jsCall}(${this.expr(callee)}${this.untypedArgs(e)})`;
|
|
166
166
|
const t = this.typeOf(e);
|
|
167
167
|
return isUntyped(spelledType(t)) || t === 'Void' ? code : this.fromAnyCode(code, t, true);
|
package/dist/swift/lenient.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Loose, lenient and tolerated reads as Swift: values non-strict code reads where its types say otherwise.
|
|
2
2
|
import ts from 'typescript';
|
|
3
3
|
import { balanced, functionParts, hasTopLevelArrow, isFunctionType, isOptional, splitTopLevel, swiftString, RT } from "./syntax.js";
|
|
4
|
-
import { accessedDeclaration, evolvingElementContext, isSelf
|
|
4
|
+
import { accessedDeclaration, evolvingElementContext, isSelf } from "../semantics/lang.js";
|
|
5
5
|
import { hasModifier, isWriteTarget, notIterable } from "../semantics/ast.js";
|
|
6
6
|
import { rethrowUnlessRefused } from "../semantics/refusals.js";
|
|
7
7
|
import { isUntyped, spelledType } from "../semantics/types.js";
|
|
@@ -294,11 +294,6 @@ export const lenientMethods = {
|
|
|
294
294
|
const t = this.typeOf(x);
|
|
295
295
|
return !isFunctionType(t) && this.nullableRef(t) !== t;
|
|
296
296
|
},
|
|
297
|
-
/** A variable declared without a type whose value is a read of a signal holding null (`const card = this.morning()`). */
|
|
298
|
-
givenNullSignalValue(n) {
|
|
299
|
-
const init = untypedVariableInitializer(n, (id) => this.resolve(id));
|
|
300
|
-
return !!init && this.nullSignalRead(init);
|
|
301
|
-
},
|
|
302
297
|
nullSignalRead(e) {
|
|
303
298
|
if (!ts.isCallExpression(e) || e.arguments.length || !['writable', 'input', 'computed'].includes(this.framework.signalKind(this.symbolName(e.expression)) ?? ''))
|
|
304
299
|
return false;
|
package/dist/swift/library.js
CHANGED
|
@@ -19,8 +19,8 @@ export const BUILTIN_CLASSES = Object.assign(Object.create(null), { Promise: 'JS
|
|
|
19
19
|
export const LIB_FUNCTION_VALUES = {
|
|
20
20
|
clearTimeout: { code: `{ (__id: Any?) -> Void in ${RT.jsClearTimeout}(${RT.jsIsNullish}(__id) ? nil : ${RT.jsToNumber}(__id)) }`, type: '(Any?) throws -> Void' },
|
|
21
21
|
clearInterval: { code: `{ (__id: Any?) -> Void in ${RT.jsClearInterval}(${RT.jsIsNullish}(__id) ? nil : ${RT.jsToNumber}(__id)) }`, type: '(Any?) throws -> Void' },
|
|
22
|
-
queueMicrotask: { code: `{ (__f: @escaping () throws -> Void) -> Void in ${RT.jsQueueMicrotask} { ${RT.jsReport} { try __f() } } }`, type: '(() throws -> Void) throws -> Void' },
|
|
23
|
-
requestAnimationFrame: { code: `{ (__f: @escaping (Double) throws -> Void) -> Double in ${RT.jsRequestAnimationFrame} { __t in ${RT.jsReport} { try __f(__t) } } }`, type: '((Double) throws -> Void) throws -> Double' },
|
|
22
|
+
queueMicrotask: { code: `{ (__f: @escaping () throws -> Void) -> Void in ${RT.jsQueueMicrotask} { ${RT.jsReport} { try __f() } } }`, type: '(@escaping () throws -> Void) throws -> Void' },
|
|
23
|
+
requestAnimationFrame: { code: `{ (__f: @escaping (Double) throws -> Void) -> Double in ${RT.jsRequestAnimationFrame} { __t in ${RT.jsReport} { try __f(__t) } } }`, type: '(@escaping (Double) throws -> Void) throws -> Double' },
|
|
24
24
|
cancelAnimationFrame: { code: `{ (__id: Double?) -> Void in ${RT.jsCancelAnimationFrame}(__id) }`, type: '(Double?) throws -> Void' },
|
|
25
25
|
};
|
|
26
26
|
/** `Math`'s functions, by the Swift function each is. */
|
package/dist/swift/literals.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Literals as Swift: arrays, objects and dynamic objects.
|
|
2
2
|
import ts from 'typescript';
|
|
3
|
-
import { functionParts, ident, identPath, initOrder, isNullish, isOptional, label, optionalType, splitTopLevel, swiftString, withoutThenables, spell, RT } from "./syntax.js";
|
|
3
|
+
import { functionParts, ident, identPath, implicitType, initOrder, isNullish, isOptional, label, optionalType, splitTopLevel, swiftString, withoutThenables, spell, RT } from "./syntax.js";
|
|
4
4
|
import { assertedOperand, evolvingElementContext, intersectionAliasMembers, isTypeParameterType, literalKey, openSpreadType, spreadOperand, unquoted } from "../semantics/lang.js";
|
|
5
5
|
import { place } from "../semantics/placement.js";
|
|
6
6
|
import { holdsNil, literalNotes, signatureField, shapePlanOfLiteral, spelledOptional, spreadElementNeedsMap, resultShapeNamed } from "../semantics/shapes.js";
|
|
@@ -300,7 +300,7 @@ export const literalsMethods = {
|
|
|
300
300
|
}
|
|
301
301
|
};
|
|
302
302
|
// A field the class holds implicitly unwrapped (`shapeHeld`) takes what the literal gives as optional, undefined included.
|
|
303
|
-
const loose = (want) => !!want && target === name && this.shapeHeld({ type: want }) ===
|
|
303
|
+
const loose = (want) => !!want && target === name && this.shapeHeld({ type: want }) === implicitType(want);
|
|
304
304
|
// Methods that read `this` see the object through a weak reference the literal sets once it exists.
|
|
305
305
|
// A function expression as a member (`onViewLoaded: function () { this.loadedCount++ }`) reads the object as `this` too.
|
|
306
306
|
const thisFunction = (p) => ts.isPropertyAssignment(p) && ts.isFunctionExpression(p.initializer) && thisNodes(p.initializer).length > 0;
|
|
@@ -390,7 +390,12 @@ export const literalsMethods = {
|
|
|
390
390
|
}
|
|
391
391
|
else if (ts.isMethodDeclaration(p)) {
|
|
392
392
|
const key = literalKey(p.name, this.checker) ?? this.symbolMemberName(p.name) ?? p.name.getText();
|
|
393
|
-
const
|
|
393
|
+
const fieldType = order.find((f) => f.name === key)?.type ?? '';
|
|
394
|
+
if (isUntyped(spelledType(fieldType))) {
|
|
395
|
+
given.set(key, this.untypedMethod(p));
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
const want = functionParts(fieldType.replace(/^\((.*)\)[?!]$/, '$1'));
|
|
394
399
|
// An unannotated method returning an object literal makes it against its field's declared result, as TypeScript types the returned literal.
|
|
395
400
|
const sig = !p.type && want && want.result !== 'Void' ? this.checker.getSignatureFromDeclaration(p) : undefined;
|
|
396
401
|
const literalResult = !!sig && !!this.checker.getReturnTypeOfSignature(sig).symbol?.declarations?.some(ts.isObjectLiteralExpression);
|
|
@@ -136,7 +136,8 @@ export const methodValuesMethods = {
|
|
|
136
136
|
const params = fn.parameters.filter((p) => !(ts.isIdentifier(p.name) && p.name.text === 'this'));
|
|
137
137
|
const ret = this.returnTypeOf(fn);
|
|
138
138
|
const localType = (p) => (p.questionToken || (p.initializer && !this.templateParams) ? this.paramType(p) : this.states.mayBeNull(p) ? (this.lenient ? optionalType(this.typeOf(p.name)) : `${this.typeOf(p.name)}!`) : this.paramType(p));
|
|
139
|
-
const
|
|
139
|
+
const rawSelf = declaresThis(fn) ? localType(fn.parameters[0]) : 'Any?';
|
|
140
|
+
const selfType = !isUntyped(spelledType(rawSelf)) && !this.declaredNullable(fn.parameters[0]) ? rawSelf.replace(/\?$/, '!') : rawSelf;
|
|
140
141
|
const selfBind = !isUntyped(spelledType(selfType)) ? [`let __self: ${selfType} = ${this.presentFromAny('__this', selfType.replace(/!$/, '?'), true, true)}`] : [];
|
|
141
142
|
// A function reading `arguments` binds its parameters from them itself.
|
|
142
143
|
const binds = [
|
package/dist/swift/modules.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Module-level declarations as Swift: modules, variables, namespaces, constants, interfaces and protocols.
|
|
2
2
|
import { setLossSite } from "../semantics/losses.js";
|
|
3
3
|
import ts from 'typescript';
|
|
4
|
-
import { NONISOLATED_DEINIT, SWIFT_GLOBAL_FUNCTIONS, escapingFunction, functionParts, ident, identPath, indented, isFunctionType, isNullish, isOptional, nativeResult, nativeZero, optionalType, swiftString, RT } from "./syntax.js";
|
|
4
|
+
import { NONISOLATED_DEINIT, SWIFT_GLOBAL_FUNCTIONS, escapingFunction, functionParts, ident, identPath, implicitType, indented, isFunctionType, isNullish, isOptional, nativeResult, nativeZero, optionalType, swiftString, RT } from "./syntax.js";
|
|
5
5
|
import { lookupClass, lookupMember } from "./native/sdk.js";
|
|
6
6
|
import { boundNames, hasModifier, isLibDeclaration, moduleBlockVars, redeclaredVar } from "../semantics/ast.js";
|
|
7
7
|
import { enteredGuard, onMainThread } from "./native/bridging.js";
|
|
@@ -684,7 +684,7 @@ export const modulesMethods = {
|
|
|
684
684
|
});
|
|
685
685
|
const signature = (m) => `func ${m.name}(${m.params.map((p) => `_ ${p.name}: ${isFunctionType(p.type) ? `@escaping ${p.type}` : p.type}`).join(', ')}) throws${m.ret === 'Void' ? '' : ` -> ${m.ret}`}`;
|
|
686
686
|
const fnType = (m) => `(${m.params.map((p) => p.type).join(', ')}) throws -> ${m.ret.replace(/!$/, '?')}`;
|
|
687
|
-
const lines = [
|
|
687
|
+
const lines = [`@MainActor protocol ${name}: JSDynamic {`];
|
|
688
688
|
const params = (m) => m.params.map((p) => `_ ${p.name}: ${isFunctionType(p.type) ? `@escaping ${p.type}` : p.type}`).join(', ');
|
|
689
689
|
const requirements = (owner) => {
|
|
690
690
|
for (const f of fields)
|
|
@@ -938,7 +938,7 @@ ${members.join('\n')}
|
|
|
938
938
|
return isFunctionType(f.type) ? `(${f.type})?` : this.nullableRef(f.type);
|
|
939
939
|
// An app's object field holds undefined too, as a literal asserted to the type may give it (`{ …, view } as
|
|
940
940
|
// ItemEventData` before the view exists); a read that uses it unwraps it there.
|
|
941
|
-
return !this.library && !isOptional(f.type) && !f.type.endsWith('!') && !isFunctionType(f.type) && this.nullableRef(f.type) !== f.type ?
|
|
941
|
+
return !this.library && !isOptional(f.type) && !f.type.endsWith('!') && !isFunctionType(f.type) && this.nullableRef(f.type) !== f.type ? implicitType(f.type) : f.type;
|
|
942
942
|
},
|
|
943
943
|
membersWritten() {
|
|
944
944
|
return this.facts.assignedMembers();
|
package/dist/swift/names.js
CHANGED
|
@@ -56,6 +56,10 @@ export const namesMethods = {
|
|
|
56
56
|
// A name nothing declares for iOS (`android`, `java`, Node's `__dirname`) is a value whose use throws.
|
|
57
57
|
if (name === 'global' && (this.library ? !libDecl || libDecl.getSourceFile().isDeclarationFile : !!libDecl && libDecl.getSourceFile().isDeclarationFile))
|
|
58
58
|
return 'jsGlobalThis';
|
|
59
|
+
// A timer or microtask function held as a value (`const clear = clearTimeout`, `requestAnimationFrame`, `queueMicrotask`), core's declaration of it too.
|
|
60
|
+
const held = !!libDecl && libDecl.getSourceFile().isDeclarationFile && Object.hasOwn(LIB_FUNCTION_VALUES, name) && !(ts.isCallExpression(e.parent) && e.parent.expression === e) ? LIB_FUNCTION_VALUES[name] : undefined;
|
|
61
|
+
if (held)
|
|
62
|
+
return this.convert(held.code, held.type, this.typeOf(e));
|
|
59
63
|
if (this.isDomGlobal(e))
|
|
60
64
|
return `jsGlobalThis[jsKey: ${swiftString(name)}]`;
|
|
61
65
|
// The runtime gives the bundled app's module its folder in the app bundle.
|
|
@@ -81,10 +85,6 @@ export const namesMethods = {
|
|
|
81
85
|
return sdk;
|
|
82
86
|
return this.fromAnyCode(`jsGlobalThis[jsKey: ${swiftString(name)}]`, this.typeOf(e));
|
|
83
87
|
}
|
|
84
|
-
// A timer or microtask function held as a value (`const clear = clearTimeout`), core's declaration of it too.
|
|
85
|
-
const held = !!libDecl && libDecl.getSourceFile().isDeclarationFile && Object.hasOwn(LIB_FUNCTION_VALUES, name) && !(ts.isCallExpression(e.parent) && e.parent.expression === e) ? LIB_FUNCTION_VALUES[name] : undefined;
|
|
86
|
-
if (held)
|
|
87
|
-
return this.convert(held.code, held.type, this.typeOf(e));
|
|
88
88
|
// A global function core or the app only declares (`zonedCallback`, which core's globals set), as a value: the global object's.
|
|
89
89
|
if (!this.library && libDecl && ts.isFunctionDeclaration(libDecl) && !libDecl.body && (appAmbient || isCoreDeclaration(libDecl)) && ts.isSourceFile(libDecl.parent) && !hasModifier(libDecl, ts.SyntaxKind.ExportKeyword))
|
|
90
90
|
return 'jsGlobalThis[jsKey: ' + swiftString(name) + ']';
|
|
@@ -186,7 +186,7 @@ export const namesMethods = {
|
|
|
186
186
|
* App mode: a type name Swift code already has unqualified (the standard library's, the runtime's, the app module's own
|
|
187
187
|
* Swift, or a native module's the app imports), which a program type of that name would hide from the app.
|
|
188
188
|
*/
|
|
189
|
-
|
|
189
|
+
swiftTypeClash(name) {
|
|
190
190
|
return !this.library && (SWIFT_NATIVE_TYPES.has(name) || runtimeTypeName(name) || this.appSwiftNames.has(name) || this.importedTypeNames().has(name));
|
|
191
191
|
},
|
|
192
192
|
/** The Swift type names of `nativeModules` and of the SDK modules whose declarations the program's code names. */
|
|
@@ -276,7 +276,7 @@ export const namesMethods = {
|
|
|
276
276
|
this.kitClashes.push(name);
|
|
277
277
|
// A type the hand-written kit declares for itself (Signals' `Source`), or an app's type named as one Swift has already
|
|
278
278
|
// (`Result`): the generated one takes its module's name.
|
|
279
|
-
const internalClash = !!this.library?.internalTypes?.has(name) || (list.some((x) => typeLike(x.decl) || ts.isInterfaceDeclaration(x.decl)) && this.
|
|
279
|
+
const internalClash = !!this.library?.internalTypes?.has(name) || (list.some((x) => typeLike(x.decl) || ts.isInterfaceDeclaration(x.decl)) && this.swiftTypeClash(name));
|
|
280
280
|
if (list.length < 2 && !kitClash && !internalClash)
|
|
281
281
|
continue;
|
|
282
282
|
// The app's first declaration keeps its name; the others take their module's.
|
|
@@ -326,7 +326,7 @@ export const namesMethods = {
|
|
|
326
326
|
if (ts.isModuleDeclaration(st))
|
|
327
327
|
collect(st);
|
|
328
328
|
for (const [name, list] of hoisted) {
|
|
329
|
-
if (!byName.has(name) && list.length < 2 && !this.core.has(name) && !this.
|
|
329
|
+
if (!byName.has(name) && list.length < 2 && !this.core.has(name) && !this.swiftTypeClash(name))
|
|
330
330
|
continue;
|
|
331
331
|
for (const x of list)
|
|
332
332
|
this.renamedTop.set(x.decl, `${name}__${(this.namespacePath(x.ns) ?? '').replace(/\./g, '_')}`);
|
|
@@ -435,7 +435,7 @@ export const nativeCallsMethods = {
|
|
|
435
435
|
* Whether a typings declaration's Swift binding holds nil (an optional): a property's value, a method's result, a
|
|
436
436
|
* parameter's argument, or a parameter of a block the method takes. False where the tables have no such member.
|
|
437
437
|
*/
|
|
438
|
-
|
|
438
|
+
iosHoldsNil(d) {
|
|
439
439
|
try {
|
|
440
440
|
const block = ts.isParameter(d) && ts.isFunctionTypeNode(d.parent) && ts.isParameter(d.parent.parent) ? d.parent.parent : null;
|
|
441
441
|
const param = block ?? (ts.isParameter(d) ? d : null);
|
|
@@ -531,7 +531,7 @@ export const nativeCallsMethods = {
|
|
|
531
531
|
const k = lookupConstant(native.module, native.name);
|
|
532
532
|
if (!k)
|
|
533
533
|
throw this.t.error(e, `${native.name} (${this.noCounterpart(native.module, native.name)})`, 'native');
|
|
534
|
-
this.usesEnumOf(k, native.module, native.name);
|
|
534
|
+
this.usesEnumOf(k, native.module, native.name, e);
|
|
535
535
|
return this.fromSwift(k.swift, k.type, e);
|
|
536
536
|
},
|
|
537
537
|
/**
|
|
@@ -544,16 +544,22 @@ export const nativeCallsMethods = {
|
|
|
544
544
|
if (!k)
|
|
545
545
|
continue;
|
|
546
546
|
this.uses(module);
|
|
547
|
-
this.usesEnumOf(k, module, e.text);
|
|
547
|
+
this.usesEnumOf(k, module, e.text, e);
|
|
548
548
|
return this.fromSwift(k.swift, k.type, e);
|
|
549
549
|
}
|
|
550
550
|
return null;
|
|
551
551
|
},
|
|
552
552
|
/** A typed constant's enum is looked up among the modules in use, and may live in another table than the typings' module. */
|
|
553
|
-
usesEnumOf(k, module, jsName) {
|
|
553
|
+
usesEnumOf(k, module, jsName, e) {
|
|
554
|
+
this.checkAvailable(k, e, jsName);
|
|
554
555
|
const home = k.enumType ? constantModule(module, jsName) : null;
|
|
555
556
|
if (home)
|
|
556
557
|
this.uses(home);
|
|
558
|
+
if (k.enumType) {
|
|
559
|
+
const en = lookupEnum(home ?? module, k.enumType);
|
|
560
|
+
if (en)
|
|
561
|
+
this.checkAvailable(en, e, k.enumType);
|
|
562
|
+
}
|
|
557
563
|
},
|
|
558
564
|
/** A native function of no arguments as a value (`isRunning = UIAccessibilityIsVoiceOverRunning`): a closure calling it, as Swift may have it as a property. */
|
|
559
565
|
functionValue(e, native) {
|
|
@@ -16,8 +16,19 @@ export const objectClassesMethods = {
|
|
|
16
16
|
// A view keeps no fields: each reads and writes its root's key, and its own object's fields are `jsOwn`'s. A result
|
|
17
17
|
// interface's class in the kit has one for an app's untyped object of it.
|
|
18
18
|
const view = !symbolic.length && !keyed.length && (this.library ? resultShapeNamed(this, name) : this.viewed.has(name));
|
|
19
|
+
// Fast direct JSON writer for plain shapes (no views, symbols, Any, functions, BigInt, or declared toJSON).
|
|
20
|
+
const fastJSON = !this.library &&
|
|
21
|
+
!view &&
|
|
22
|
+
!symbolic.length &&
|
|
23
|
+
!keyed.length &&
|
|
24
|
+
fields.length > 0 &&
|
|
25
|
+
!fields.some((f) => {
|
|
26
|
+
const h = this.shapeHeld(f);
|
|
27
|
+
const base = h.replace(/[?!]$/, '');
|
|
28
|
+
return f.name === 'toJSON' || base === 'Any' || isFunctionType(base.replace(/^\((.*)\)$/, '$1')) || /^JS(Nullish|BigInt)\b/.test(base);
|
|
29
|
+
});
|
|
19
30
|
this.shapesWritten.add(name);
|
|
20
|
-
const lines = [`final class ${name}: ${['JSDynamic', ...this.shapeProtocols(allFields).map((x) => x.conformance), ...(symbolic.length ? [] : ['JSObjectConvertible']), ...(view ? ['JSViewing'] : []), ...(keyed.length ? ['JSSymbolKeyed'] : [])].join(', ')} {`, NONISOLATED_DEINIT];
|
|
31
|
+
const lines = [`final class ${name}: ${['JSDynamic', ...this.shapeProtocols(allFields).map((x) => x.conformance), ...(symbolic.length ? [] : ['JSObjectConvertible']), ...(fastJSON ? ['JSJSONFastSerializable'] : []), ...(view ? ['JSViewing'] : []), ...(keyed.length ? ['JSSymbolKeyed'] : [])].join(', ')} {`, NONISOLATED_DEINIT];
|
|
21
32
|
const held = (f) => this.shapeHeld(f);
|
|
22
33
|
// A field the object lacks, or holds of another type (JSON without an optional field), reads as JavaScript converts it where used.
|
|
23
34
|
const fieldType = (f) => (this.lenient ? held(f).replace(/^\((.*)\)!$/, '($1)?') : held(f).endsWith('!') ? optionalType(f.type) : f.type);
|
|
@@ -109,6 +120,78 @@ export const objectClassesMethods = {
|
|
|
109
120
|
}
|
|
110
121
|
members[0] = ` var jsKeys: [String] {\n${view ? ' if let __r = jsRoot { return __r.jsKeys }\n' : ''} let order = jsOrder ?? ${declared}\n let keys = order + (jsExtra?.jsKeys ?? []).filter { !order.contains($0) }\n return ${optional.length ? 'keys.filter(jsHas)' : 'keys'}\n }`;
|
|
111
122
|
lines.push(...members);
|
|
123
|
+
if (fastJSON) {
|
|
124
|
+
const canFast = ['jsOrder == nil', 'jsExtra == nil', ...(nullable.length ? ['jsNulls == nil'] : []), ...(optional.length ? ['jsUnset == nil'] : [])].join(' && ');
|
|
125
|
+
const safe = (f) => ['Double', 'String', 'Bool'].includes(this.shapeHeld(f));
|
|
126
|
+
const guaranteedFirst = safe(fields[0]);
|
|
127
|
+
const steps = [];
|
|
128
|
+
if (guaranteedFirst) {
|
|
129
|
+
fields.forEach((f, idx) => {
|
|
130
|
+
const h = this.shapeHeld(f);
|
|
131
|
+
const opt = h.endsWith('?');
|
|
132
|
+
const base = h.replace(/[?!]$/, '');
|
|
133
|
+
const ref = `self.${ident(memberOf(f))}`;
|
|
134
|
+
const keyLit = JSON.stringify(f.name);
|
|
135
|
+
const prefix = idx === 0 ? `{${keyLit}:` : `,${keyLit}:`;
|
|
136
|
+
if (!opt && h === 'Double')
|
|
137
|
+
steps.push(` out.appendJSONLiteral(${swiftString(prefix)}); out.appendJSONNumber(${ref})`);
|
|
138
|
+
else if (!opt && h === 'String')
|
|
139
|
+
steps.push(` out.appendJSONLiteral(${swiftString(prefix)}); out.appendJSONString(${ref})`);
|
|
140
|
+
else if (!opt && h === 'Bool')
|
|
141
|
+
steps.push(` out.appendJSONLiteral(${swiftString(prefix)}); out.appendJSONBool(${ref})`);
|
|
142
|
+
else if (opt && base === 'Double')
|
|
143
|
+
steps.push(` if let __v = ${ref} { out.appendJSONLiteral(${swiftString(prefix)}); out.appendJSONNumber(__v) }`);
|
|
144
|
+
else if (opt && base === 'String')
|
|
145
|
+
steps.push(` if let __v = ${ref} { out.appendJSONLiteral(${swiftString(prefix)}); out.appendJSONString(__v) }`);
|
|
146
|
+
else if (opt && base === 'Bool')
|
|
147
|
+
steps.push(` if let __v = ${ref} { out.appendJSONLiteral(${swiftString(prefix)}); out.appendJSONBool(__v) }`);
|
|
148
|
+
else if (base === 'JSArray<Double>')
|
|
149
|
+
steps.push(` if !out.appendJSONNumbersIfPlain(${swiftString(prefix)}, ${ref}) { try writeField(${swiftString(prefix)}, ${swiftString(f.name)}, ${ref}) }`);
|
|
150
|
+
else if (base === 'JSArray<String>')
|
|
151
|
+
steps.push(` if !out.appendJSONStringsIfPlain(${swiftString(prefix)}, ${ref}) { try writeField(${swiftString(prefix)}, ${swiftString(f.name)}, ${ref}) }`);
|
|
152
|
+
else
|
|
153
|
+
steps.push(` try writeField(${swiftString(prefix)}, ${swiftString(f.name)}, ${ref})`);
|
|
154
|
+
});
|
|
155
|
+
steps.push(' out.appendJSONLiteral("}")');
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
steps.push(' out.appendJSONLiteral("{")');
|
|
159
|
+
steps.push(' var __first = true');
|
|
160
|
+
const needsMark = fields.some((f) => !['Double', 'String', 'Bool'].includes(this.shapeHeld(f).replace(/\?$/, '')));
|
|
161
|
+
if (needsMark)
|
|
162
|
+
steps.push(' var __m = 0');
|
|
163
|
+
for (const f of fields) {
|
|
164
|
+
const h = this.shapeHeld(f);
|
|
165
|
+
const opt = h.endsWith('?');
|
|
166
|
+
const base = h.replace(/[?!]$/, '');
|
|
167
|
+
const ref = `self.${ident(memberOf(f))}`;
|
|
168
|
+
const keyLit = JSON.stringify(f.name);
|
|
169
|
+
const p0 = `${keyLit}:`;
|
|
170
|
+
const p1 = `,${keyLit}:`;
|
|
171
|
+
const pExpr = `__first ? ${swiftString(p0)} : ${swiftString(p1)}`;
|
|
172
|
+
if (!opt && h === 'Double')
|
|
173
|
+
steps.push(` out.appendJSONLiteral(${pExpr}); out.appendJSONNumber(${ref}); __first = false`);
|
|
174
|
+
else if (!opt && h === 'String')
|
|
175
|
+
steps.push(` out.appendJSONLiteral(${pExpr}); out.appendJSONString(${ref}); __first = false`);
|
|
176
|
+
else if (!opt && h === 'Bool')
|
|
177
|
+
steps.push(` out.appendJSONLiteral(${pExpr}); out.appendJSONBool(${ref}); __first = false`);
|
|
178
|
+
else if (opt && base === 'Double')
|
|
179
|
+
steps.push(` if let __v = ${ref} { out.appendJSONLiteral(${pExpr}); out.appendJSONNumber(__v); __first = false }`);
|
|
180
|
+
else if (opt && base === 'String')
|
|
181
|
+
steps.push(` if let __v = ${ref} { out.appendJSONLiteral(${pExpr}); out.appendJSONString(__v); __first = false }`);
|
|
182
|
+
else if (opt && base === 'Bool')
|
|
183
|
+
steps.push(` if let __v = ${ref} { out.appendJSONLiteral(${pExpr}); out.appendJSONBool(__v); __first = false }`);
|
|
184
|
+
else if (base === 'JSArray<Double>')
|
|
185
|
+
steps.push(` __m = out.count; if !out.appendJSONNumbersIfPlain(${pExpr}, ${ref}) { try writeField(${pExpr}, ${swiftString(f.name)}, ${ref}) }; if out.count != __m { __first = false }`);
|
|
186
|
+
else if (base === 'JSArray<String>')
|
|
187
|
+
steps.push(` __m = out.count; if !out.appendJSONStringsIfPlain(${pExpr}, ${ref}) { try writeField(${pExpr}, ${swiftString(f.name)}, ${ref}) }; if out.count != __m { __first = false }`);
|
|
188
|
+
else
|
|
189
|
+
steps.push(` __m = out.count; try writeField(${pExpr}, ${swiftString(f.name)}, ${ref}); if out.count != __m { __first = false }`);
|
|
190
|
+
}
|
|
191
|
+
steps.push(' out.appendJSONLiteral("}")');
|
|
192
|
+
}
|
|
193
|
+
lines.push(` var jsCanFastJSON: Bool { ${canFast} }`, ' func jsWriteJSONFast(to out: JSUTF8Buffer, writeField: (StaticString, String, Any?) throws -> Void) throws -> Bool {', ' if !jsCanFastJSON { return false }', ...steps, ' return true', ' }');
|
|
194
|
+
}
|
|
112
195
|
lines.push('}');
|
|
113
196
|
return lines.join('\n');
|
|
114
197
|
},
|
package/dist/swift/operators.js
CHANGED
|
@@ -12,7 +12,7 @@ import { constClassExpr, hasInstanceClass } from "../semantics/classes.js";
|
|
|
12
12
|
import { isUntyped, spelledType } from "../semantics/types.js";
|
|
13
13
|
import { bigIntArithmetic, bigIntCompare, bigIntPlan } from "../semantics/apis/bigint.js";
|
|
14
14
|
import { BIT_ASSIGNMENTS, addCall, bitOperation, concatOperand, numericThrowing, untypedBinary, untypedConversion } from "../semantics/apis/operators.js";
|
|
15
|
-
import { planRelational } from "../semantics/lower.js";
|
|
15
|
+
import { planArithmetic, planEquality, planLogicalAssign, planRelational, typeofComparison } from "../semantics/lower.js";
|
|
16
16
|
/** BigInt's operations the backend spells as an operator. */
|
|
17
17
|
const BIGINT_INFIX = { add: '+', subtract: '-', multiply: '*', and: '&', or: '|', xor: '^' };
|
|
18
18
|
export const operatorsMethods = {
|
|
@@ -126,29 +126,32 @@ export const operatorsMethods = {
|
|
|
126
126
|
return assigned(() => `${l()} ?? ${(isOptional(this.declaredTypeOf(e.left) ?? this.typeOf(e.left)) ? this.maybeUndefined(e.right) : null) ?? this.stored(e.right, e.left, this.typeOf(e.left).replace(/\?$/, ''))}`);
|
|
127
127
|
return this.marks.blockCode(`if ${this.tryPrefix(e.left)}${RT.jsIsNullish}(${l()}) { ${this.tryPrefix(e.right)}${target()} = ${(isOptional(this.declaredTypeOf(e.left) ?? this.typeOf(e.left)) ? this.maybeUndefined(e.right) : null) ?? this.stored(e.right, e.left, this.typeOf(e.left).replace(/\?$/, ''))} }`);
|
|
128
128
|
case K.BarBarEqualsToken:
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return this.marks.blockCode(`if ${RT.jsTruthy}(${this.tryPrefix(e.left)}${l()}) { ${this.tryPrefix(e)}${target()} = ${this.stored(e.right, e.left, this.typeOf(e.left))} }`);
|
|
132
|
-
case K.PlusToken: {
|
|
133
|
-
if (this.isString(e.left) || this.isString(e.right))
|
|
134
|
-
return this.marks.infix(concatOperand(this, e.left, untyped), '+', concatOperand(this, e.right, untyped));
|
|
135
|
-
if (this.isAny(e.left) || this.isAny(e.right)) {
|
|
136
|
-
const sum = addCall(this, e, untyped), t = this.typeOf(e);
|
|
137
|
-
return isUntyped(spelledType(t)) ? sum : this.fromAnyCode(sum, t);
|
|
138
|
-
}
|
|
139
|
-
return this.marks.infix(this.toNumber(e.left), '+', this.toNumber(e.right));
|
|
129
|
+
case K.AmpersandAmpersandEqualsToken: {
|
|
130
|
+
const plan = planLogicalAssign(op);
|
|
131
|
+
return this.marks.blockCode(`if ${plan.op === '||=' ? '!' : ''}${RT.jsTruthy}(${this.tryPrefix(e.left)}${l()}) { ${this.tryPrefix(e)}${target()} = ${this.stored(e.right, e.left, this.typeOf(e.left))} }`);
|
|
140
132
|
}
|
|
133
|
+
case K.PlusToken:
|
|
141
134
|
case K.MinusToken:
|
|
142
|
-
return this.marks.infix(this.toNumber(e.left), '-', this.toNumber(e.right));
|
|
143
135
|
case K.AsteriskToken:
|
|
144
|
-
return this.marks.infix(this.toNumber(e.left), '*', this.toNumber(e.right));
|
|
145
|
-
// Integer literals on both sides would divide as Int where no operand pins Double (`Double(1 / 8)`, `js(16 / 9)`).
|
|
146
136
|
case K.SlashToken:
|
|
147
|
-
return numericLiteralOnly(e.left) && numericLiteralOnly(e.right) ? `(${this.expr(e.left)} as Double) / ${this.expr(e.right)}` : this.marks.infix(this.toNumber(e.left), '/', this.toNumber(e.right));
|
|
148
137
|
case K.PercentToken:
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
138
|
+
case K.AsteriskAsteriskToken: {
|
|
139
|
+
const plan = planArithmetic(op, this.isString(e.left), this.isString(e.right), this.isAny(e.left), this.isAny(e.right));
|
|
140
|
+
if (plan.kind === 'concat')
|
|
141
|
+
return this.marks.infix(concatOperand(this, e.left, untyped), '+', concatOperand(this, e.right, untyped));
|
|
142
|
+
if (plan.kind === 'dynamicAdd') {
|
|
143
|
+
const sum = addCall(this, e, untyped), t = this.typeOf(e);
|
|
144
|
+
return isUntyped(spelledType(t)) ? sum : this.fromAnyCode(sum, t);
|
|
145
|
+
}
|
|
146
|
+
// Integer literals on both sides would divide as Int where no operand pins Double (`Double(1 / 8)`, `js(16 / 9)`).
|
|
147
|
+
if (plan.op === '/' && numericLiteralOnly(e.left) && numericLiteralOnly(e.right))
|
|
148
|
+
return `(${this.expr(e.left)} as Double) / ${this.expr(e.right)}`;
|
|
149
|
+
if (plan.op === '%')
|
|
150
|
+
return `${RT.jsMod}(${this.toNumber(e.left)}, ${this.toNumber(e.right)})`;
|
|
151
|
+
if (plan.op === '**')
|
|
152
|
+
return `${RT.jsPow}(${this.toNumber(e.left)}, ${this.toNumber(e.right)})`;
|
|
153
|
+
return this.marks.infix(this.toNumber(e.left), plan.op, this.toNumber(e.right));
|
|
154
|
+
}
|
|
152
155
|
case K.EqualsEqualsEqualsToken:
|
|
153
156
|
case K.ExclamationEqualsEqualsToken:
|
|
154
157
|
case K.EqualsEqualsToken:
|
|
@@ -446,24 +449,23 @@ export const operatorsMethods = {
|
|
|
446
449
|
* there, a nil check. Null where the test is not one of presence.
|
|
447
450
|
*/
|
|
448
451
|
typeofPresence(e) {
|
|
449
|
-
const
|
|
450
|
-
|
|
451
|
-
const [t, lit] = ts.isTypeOfExpression(l) && ts.isStringLiteralLike(r) ? [l, r] : ts.isTypeOfExpression(r) && ts.isStringLiteralLike(l) ? [r, l] : [null, null];
|
|
452
|
-
if (!t || !lit)
|
|
452
|
+
const cmp = typeofComparison(e);
|
|
453
|
+
if (!cmp)
|
|
453
454
|
return null;
|
|
455
|
+
const left = ts.skipOuterExpressions(e.left, ts.OuterExpressionKinds.Parentheses);
|
|
456
|
+
const t = (ts.isTypeOfExpression(left) ? left : ts.skipOuterExpressions(e.right, ts.OuterExpressionKinds.Parentheses));
|
|
454
457
|
const c = this.typeofCell(t);
|
|
455
|
-
if (c.cell !== 'presence' || (
|
|
458
|
+
if (c.cell !== 'presence' || (cmp.tag !== 'undefined' && cmp.tag !== c.type))
|
|
456
459
|
return null;
|
|
457
|
-
|
|
458
|
-
return `${c.tested} ${(lit.text === 'undefined') !== negate ? '==' : '!='} nil`;
|
|
460
|
+
return `${c.tested} ${(cmp.tag === 'undefined') !== cmp.negated ? '==' : '!='} nil`;
|
|
459
461
|
},
|
|
460
462
|
equality(e) {
|
|
461
463
|
this.refuseUnheldIdentity(e.left);
|
|
462
464
|
this.refuseUnheldIdentity(e.right);
|
|
463
465
|
const K = ts.SyntaxKind;
|
|
464
|
-
const
|
|
465
|
-
const negate =
|
|
466
|
-
const strict =
|
|
466
|
+
const eq = planEquality(e.operatorToken.kind, false, false, false, false);
|
|
467
|
+
const negate = eq.negated;
|
|
468
|
+
const strict = eq.kind === 'strict';
|
|
467
469
|
const isNullish = (x) => x.kind === K.NullKeyword || (ts.isIdentifier(x) && x.text === 'undefined');
|
|
468
470
|
const [a, b] = [e.left, e.right];
|
|
469
471
|
const lt = this.typeOf(a);
|