Skip to content

Commit b10bee6

Browse files
Merge pull request swiftwasm#650 from PassiveLogic/kr/runtime-lint-fixes
Runtime: Fix lint issues in compiled output
2 parents 2dc9a66 + 7fbf3e1 commit b10bee6

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

Plugins/PackageToJS/Templates/runtime.mjs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const decode = (kind, payload1, payload2, objectSpace) => {
3030
case 1:
3131
return true;
3232
}
33+
// falls through
3334
case 2 /* Kind.Number */:
3435
return payload2;
3536
case 1 /* Kind.String */:
@@ -555,7 +556,7 @@ class SwiftRuntime {
555556
swjs_call_function: (ref, argv, argc, payload1_ptr, payload2_ptr) => {
556557
const memory = this.memory;
557558
const func = memory.getObject(ref);
558-
let result = undefined;
559+
let result;
559560
try {
560561
const args = decodeArray(argv, argc, this.getDataView(), memory);
561562
result = func(...args);
@@ -590,9 +591,8 @@ class SwiftRuntime {
590591
const memory = this.memory;
591592
const obj = memory.getObject(obj_ref);
592593
const func = memory.getObject(func_ref);
593-
let result = undefined;
594594
const args = decodeArray(argv, argc, this.getDataView(), memory);
595-
result = func.apply(obj, args);
595+
const result = func.apply(obj, args);
596596
return writeAndReturnKindBits(result, payload1_ptr, payload2_ptr, false, this.getDataView(), this.memory);
597597
},
598598
swjs_call_new: (ref, argv, argc) => {
@@ -744,9 +744,10 @@ class SwiftRuntime {
744744
broker.onReceivingResponse(message);
745745
break;
746746
}
747-
default:
747+
default: {
748748
const unknownMessage = message;
749749
throw new Error(`Unknown message type: ${unknownMessage}`);
750+
}
750751
}
751752
});
752753
},
@@ -773,9 +774,10 @@ class SwiftRuntime {
773774
broker.onReceivingResponse(message);
774775
break;
775776
}
776-
default:
777+
default: {
777778
const unknownMessage = message;
778779
throw new Error(`Unknown message type: ${unknownMessage}`);
780+
}
779781
}
780782
});
781783
},

Runtime/src/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ export class SwiftRuntime {
430430
) => {
431431
const memory = this.memory;
432432
const func = memory.getObject(ref);
433-
let result = undefined;
433+
let result: any;
434434
try {
435435
const args = JSValue.decodeArray(
436436
argv,
@@ -534,14 +534,13 @@ export class SwiftRuntime {
534534
const memory = this.memory;
535535
const obj = memory.getObject(obj_ref);
536536
const func = memory.getObject(func_ref);
537-
let result = undefined;
538537
const args = JSValue.decodeArray(
539538
argv,
540539
argc,
541540
this.getDataView(),
542541
memory,
543542
);
544-
result = func.apply(obj, args);
543+
const result = func.apply(obj, args);
545544
return JSValue.writeAndReturnKindBits(
546545
result,
547546
payload1_ptr,
@@ -799,11 +798,12 @@ export class SwiftRuntime {
799798
broker.onReceivingResponse(message);
800799
break;
801800
}
802-
default:
801+
default: {
803802
const unknownMessage: never = message;
804803
throw new Error(
805804
`Unknown message type: ${unknownMessage}`,
806805
);
806+
}
807807
}
808808
});
809809
},
@@ -838,11 +838,12 @@ export class SwiftRuntime {
838838
broker.onReceivingResponse(message);
839839
break;
840840
}
841-
default:
841+
default: {
842842
const unknownMessage: never = message;
843843
throw new Error(
844844
`Unknown message type: ${unknownMessage}`,
845845
);
846+
}
846847
}
847848
});
848849
},

Runtime/src/js-value.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export const decode = (
3131
case 1:
3232
return true;
3333
}
34+
// falls through
3435
case Kind.Number:
3536
return payload2;
3637

0 commit comments

Comments
 (0)