@abaplint/runtime 2.1.17 → 2.1.18

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.
@@ -4,33 +4,39 @@ exports.cast = void 0;
4
4
  const compare_1 = require("../compare");
5
5
  // todo, field symbols as input?
6
6
  // todo, local classes?
7
+ // check with javascript instanceof?
8
+ // handling interfaces?
7
9
  async function cast(target, source) {
10
+ var _a;
8
11
  if ((0, compare_1.initial)(source)) {
9
12
  target.clear();
10
13
  return;
11
14
  }
12
- /*
13
- const targetName = target.getQualifiedName()?.toUpperCase();
14
- if (targetName?.startsWith("IF_") === false
15
- && targetName?.startsWith("ZIF_") === false) { // todo, interfaces are also classes but not inherited
16
- // using "instanceof" is probably wrong in some cases,
17
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof
18
- // @ts-ignore
19
- if (abap.Classes[targetName] && source instanceof abap.Classes[targetName] === false) {
20
- // @ts-ignore
21
- if (abap.Classes["CX_SY_MOVE_CAST_ERROR"] !== undefined) {
22
- // @ts-ignore
23
- throw new abap.Classes["CX_SY_MOVE_CAST_ERROR"]();
24
- } else {
25
- throw "Global class CX_SY_MOVE_CAST_ERROR not found";
15
+ // eslint-disable-next-line prefer-const
16
+ let castEnabled = true;
17
+ if (castEnabled === true) {
18
+ const targetName = (_a = target.getQualifiedName()) === null || _a === void 0 ? void 0 : _a.toUpperCase();
19
+ if ((targetName === null || targetName === void 0 ? void 0 : targetName.startsWith("IF_")) === false
20
+ && (targetName === null || targetName === void 0 ? void 0 : targetName.startsWith("ZIF_")) === false) { // todo, interfaces are also classes but not inherited
21
+ // using "instanceof" is probably wrong in some cases,
22
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof
23
+ // @ts-ignore
24
+ if (abap.Classes[targetName] && source.get() instanceof abap.Classes[targetName] === false) {
25
+ // @ts-ignore
26
+ if (abap.Classes["CX_SY_MOVE_CAST_ERROR"] !== undefined) {
27
+ // @ts-ignore
28
+ throw new abap.Classes["CX_SY_MOVE_CAST_ERROR"]();
29
+ }
30
+ else {
31
+ throw "Global class CX_SY_MOVE_CAST_ERROR not found";
32
+ }
33
+ }
26
34
  }
27
- }
35
+ target.set(source);
36
+ }
37
+ else {
38
+ target.set(source);
28
39
  }
29
- */
30
- // throw cx_sy_move_cast_error if incompatible
31
- // check with javascript instanceof?
32
- // handling interfaces?
33
- target.set(source);
34
40
  }
35
41
  exports.cast = cast;
36
42
  //# sourceMappingURL=cast.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.1.17",
3
+ "version": "2.1.18",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",