@runtime-type-inspector/transpiler 2.1.4 → 2.2.1

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.
Files changed (3) hide show
  1. package/index.cjs +154 -36
  2. package/index.mjs +149 -31
  3. package/package.json +2 -2
package/index.cjs CHANGED
@@ -345,6 +345,13 @@
345
345
  elements: elements.map(expandTypeDepFree)
346
346
  };
347
347
  }
348
+ if (type.startsWith('typeof ')) {
349
+ var argument = expandTypeDepFree(type.substring(7));
350
+ return {
351
+ type: 'typeof',
352
+ argument: argument
353
+ };
354
+ }
348
355
  if (type === 'object' || type === 'Object') {
349
356
  return {
350
357
  type: 'object',
@@ -541,6 +548,9 @@
541
548
  } else {
542
549
  warn("not an extensible type", lastTypedef);
543
550
  }
551
+ } else if (line.startsWith('@callback')) {
552
+ var _name2 = line.substring(9).trim();
553
+ typedefs[_name2] = 'Function';
544
554
  }
545
555
  }
546
556
  } catch (err) {
@@ -646,6 +656,14 @@
646
656
  if (dedicatedLine) {
647
657
  out += spaces;
648
658
  }
659
+ var multiLine = loc.start.line !== loc.end.line;
660
+ if (multiLine) {
661
+ var _this$parents$at;
662
+ if (((_this$parents$at = this.parents.at(-2)) === null || _this$parents$at === void 0 ? void 0 : _this$parents$at.type) === 'AssignmentExpression') {
663
+ spaces += ' ';
664
+ }
665
+ out += '\n' + spaces;
666
+ }
649
667
  out += '/*';
650
668
  if (value.includes('\n')) {
651
669
  value = trimEndSpaces(value.replace(/^\s*\*/gm, '*')).split('\n').filter(function (_) {
@@ -958,6 +976,23 @@
958
976
  out += ';';
959
977
  return out;
960
978
  }
979
+ }, {
980
+ key: "ClassPrivateProperty",
981
+ value: function ClassPrivateProperty(node) {
982
+ var static_ = node.static,
983
+ key = node.key,
984
+ value = node.value;
985
+ var out = this.spaces;
986
+ if (static_) {
987
+ out += 'static ';
988
+ }
989
+ out += this.toSource(key);
990
+ if (value) {
991
+ out += ' = ' + this.toSource(value);
992
+ }
993
+ out += ';';
994
+ return out;
995
+ }
961
996
  }, {
962
997
  key: "ContinueStatement",
963
998
  value: function ContinueStatement(node) {
@@ -1004,12 +1039,21 @@
1004
1039
  id = node.id,
1005
1040
  params = node.params;
1006
1041
  var out = '';
1042
+ if (node.leadingComments) {
1043
+ if (this.parentType === 'AssignmentExpression') {
1044
+ this.numSpaces++;
1045
+ }
1046
+ out += '\n' + this.spaces;
1047
+ }
1007
1048
  if (async) {
1008
1049
  out += 'async ';
1009
1050
  }
1010
1051
  var star = generator ? '*' : '';
1011
1052
  out += 'function' + star + ' ' + this.toSource(id) + this.FunctionDeclarationParams(params);
1012
1053
  out += this.toSource(body);
1054
+ if (node.leadingComments && this.parentType === 'AssignmentExpression') {
1055
+ this.numSpaces--;
1056
+ }
1013
1057
  return out;
1014
1058
  }
1015
1059
  }, {
@@ -1409,26 +1453,51 @@
1409
1453
  value: function ExportAllDeclaration(node) {
1410
1454
  return "export * from ".concat(node.source.extra.raw, ";");
1411
1455
  }
1456
+ }, {
1457
+ key: "ExportNamespaceSpecifier",
1458
+ value: function ExportNamespaceSpecifier(node) {
1459
+ var exported = node.exported;
1460
+ return '* as ' + this.toSource(exported);
1461
+ }
1412
1462
  }, {
1413
1463
  key: "ExportNamedDeclaration",
1414
1464
  value: function ExportNamedDeclaration(node) {
1415
1465
  var _this3 = this;
1416
1466
  var declaration = node.declaration,
1417
1467
  source = node.source,
1418
- specifiers = node.specifiers;
1468
+ specifiers = node.specifiers,
1469
+ loc = node.loc;
1419
1470
  var out = this.spaces;
1420
1471
  if (specifiers.length) {
1421
- out += 'export {\n';
1422
- out += this.mapToSource(specifiers).map(function (_) {
1423
- return " ".concat(_this3.spaces).concat(_);
1424
- }).join(',\n');
1425
- out += '\n';
1426
- out += this.spaces;
1427
- out += '}';
1428
- if (source) {
1429
- out += " from " + this.toSource(source);
1472
+ if (!source) {
1473
+ console.warn("ExportNamedDeclaration> no source given");
1474
+ }
1475
+ if (specifiers.length === 1 && specifiers[0].type === 'ExportNamespaceSpecifier') {
1476
+ out += 'export ';
1477
+ out += this.toSource(specifiers[0]);
1478
+ out += ' from ';
1479
+ out += this.toSource(source);
1480
+ out += ";";
1481
+ } else {
1482
+ var sameLine = loc.start.line === loc.end.line;
1483
+ if (sameLine) {
1484
+ out += 'export {';
1485
+ out += this.mapToSource(specifiers).join(', ');
1486
+ out += '}';
1487
+ } else {
1488
+ out += 'export {\n';
1489
+ out += this.mapToSource(specifiers).map(function (_) {
1490
+ return " ".concat(_this3.spaces).concat(_);
1491
+ }).join(',\n');
1492
+ out += '\n';
1493
+ out += this.spaces;
1494
+ out += '}';
1495
+ }
1496
+ if (source) {
1497
+ out += " from " + this.toSource(source);
1498
+ }
1499
+ out += ";\n";
1430
1500
  }
1431
- out += ";\n";
1432
1501
  } else if (declaration) {
1433
1502
  out += 'export ' + this.toSource(declaration);
1434
1503
  } else {
@@ -1983,9 +2052,6 @@
1983
2052
  i--;
1984
2053
  while (i >= 0) {
1985
2054
  parent = parents[i];
1986
- if (parent.type === 'CallExpression') {
1987
- break;
1988
- }
1989
2055
  if (nodeIsFunction(parent)) {
1990
2056
  break;
1991
2057
  }
@@ -2004,37 +2070,49 @@
2004
2070
  }
2005
2071
  (_console = console).warn.apply(_console, arguments);
2006
2072
  }
2073
+ }, {
2074
+ key: "getLeadingCommentsNodeForFunctionExpression",
2075
+ value: function getLeadingCommentsNodeForFunctionExpression(node) {
2076
+ var parents = this.parents;
2077
+ var i = parents.findLastIndex(function (_) {
2078
+ return _ === node;
2079
+ });
2080
+ var parent = parents[i];
2081
+ if (parent.leadingComments) {
2082
+ return parent;
2083
+ }
2084
+ i--;
2085
+ while (i >= 0) {
2086
+ parent = parents[i];
2087
+ if (nodeIsFunction(parent)) {
2088
+ break;
2089
+ }
2090
+ if (parent.leadingComments) {
2091
+ return parent;
2092
+ }
2093
+ i--;
2094
+ }
2095
+ }
2007
2096
  }, {
2008
2097
  key: "getJSDoc",
2009
2098
  value: function getJSDoc(node) {
2010
2099
  if (node.type === 'BlockStatement') {
2011
2100
  node = this.parent;
2012
2101
  }
2013
- if (node.type === 'FunctionExpression') {
2014
- if (node.leadingComments) {
2015
- this.warn("Case of FunctionExpression containing its own leadingComments is not handled");
2016
- return;
2017
- }
2018
- node = this.findParentOfType(node, 'ExpressionStatement');
2019
- if (!node) {
2020
- node = this.parents.findLast(function (_) {
2021
- return _.type === 'VariableDeclaration';
2022
- });
2023
- if (!node) {
2024
- return;
2025
- }
2026
- }
2027
- }
2028
2102
  var _node = node,
2029
2103
  leadingComments = _node.leadingComments;
2104
+ if (node.type === 'FunctionExpression') {
2105
+ var tmp = this.getLeadingCommentsNodeForFunctionExpression(node);
2106
+ leadingComments = tmp === null || tmp === void 0 ? void 0 : tmp.leadingComments;
2107
+ }
2030
2108
  if (!leadingComments) {
2031
2109
  if (node.type === 'FunctionDeclaration') {
2032
2110
  var exportNamedDeclaration = this.findParentOfType(node, 'ExportNamedDeclaration');
2033
2111
  leadingComments = exportNamedDeclaration === null || exportNamedDeclaration === void 0 ? void 0 : exportNamedDeclaration.leadingComments;
2034
2112
  }
2035
2113
  if (node.type === 'ArrowFunctionExpression') {
2036
- var tmp = this.getLeadingCommentsNodeForArrowFunctionExpression(node);
2037
- leadingComments = tmp === null || tmp === void 0 ? void 0 : tmp.leadingComments;
2114
+ var _tmp = this.getLeadingCommentsNodeForArrowFunctionExpression(node);
2115
+ leadingComments = _tmp === null || _tmp === void 0 ? void 0 : _tmp.leadingComments;
2038
2116
  }
2039
2117
  }
2040
2118
  if (leadingComments && leadingComments.length) {
@@ -2050,6 +2128,9 @@
2050
2128
  }
2051
2129
  return _defineProperty({}, paramName, parseJSDocSetter(lastComment.value, this.expandType));
2052
2130
  }
2131
+ if (lastComment.value.includes('@ignoreRTI')) {
2132
+ return;
2133
+ }
2053
2134
  return parseJSDoc(lastComment.value, this.expandType);
2054
2135
  }
2055
2136
  }
@@ -2259,6 +2340,23 @@
2259
2340
  }
2260
2341
  return out;
2261
2342
  }
2343
+ }, {
2344
+ key: "getNameForFunctionExpression",
2345
+ value: function getNameForFunctionExpression(node) {
2346
+ var objectProperty = this.findParentOfType(node, 'ObjectProperty');
2347
+ if (objectProperty) {
2348
+ return this.toSource(objectProperty.key);
2349
+ }
2350
+ var expressionStatement = this.findParentOfType(node, 'ExpressionStatement');
2351
+ if (expressionStatement) {
2352
+ var left = expressionStatement.expression.left;
2353
+ if (left) {
2354
+ return this.toSource(left);
2355
+ }
2356
+ console.warn("Asserter#getNameForFunctionExpression> expression without left");
2357
+ }
2358
+ return 'unnamed function expression';
2359
+ }
2262
2360
  }, {
2263
2361
  key: "getName",
2264
2362
  value: function getName(node) {
@@ -2288,11 +2386,7 @@
2288
2386
  if (id) {
2289
2387
  return toSource(id);
2290
2388
  }
2291
- var expressionStatement = this.findParentOfType(node, 'ExpressionStatement');
2292
- if (!expressionStatement) {
2293
- return 'unnamed function expression';
2294
- }
2295
- return toSource(expressionStatement.expression.left);
2389
+ return this.getNameForFunctionExpression(node);
2296
2390
  case 'ArrowFunctionExpression':
2297
2391
  var parent = this.findParentOfType(node, 'VariableDeclarator');
2298
2392
  if (parent) {
@@ -2471,6 +2565,9 @@
2471
2565
  ConditionalType = _ts$SyntaxKind.ConditionalType,
2472
2566
  IndexedAccessType = _ts$SyntaxKind.IndexedAccessType,
2473
2567
  RestType = _ts$SyntaxKind.RestType,
2568
+ TypeQuery = _ts$SyntaxKind.TypeQuery,
2569
+ TypeOperator = _ts$SyntaxKind.TypeOperator,
2570
+ KeyOfKeyword = _ts$SyntaxKind.KeyOfKeyword,
2474
2571
  ConstructorType = _ts$SyntaxKind.ConstructorType;
2475
2572
  switch (node.kind) {
2476
2573
  case BigIntKeyword:
@@ -2545,6 +2642,21 @@
2545
2642
  };
2546
2643
  }
2547
2644
  return ret;
2645
+ case TypeQuery:
2646
+ var argument = toSourceTS(node.exprName);
2647
+ return {
2648
+ type: 'typeof',
2649
+ argument: argument
2650
+ };
2651
+ case TypeOperator:
2652
+ if (node.operator === KeyOfKeyword) {
2653
+ var _argument = toSourceTS(node.type);
2654
+ return {
2655
+ type: 'keyof',
2656
+ argument: _argument
2657
+ };
2658
+ }
2659
+ console.warn("unimplemented TypeOperator", node);
2548
2660
  case TypeReference:
2549
2661
  {
2550
2662
  if ((typeName.text === 'Object' || typeName.text === 'Record') && (typeArguments === null || typeArguments === void 0 ? void 0 : typeArguments.length) === 2) {
@@ -2825,6 +2937,12 @@
2825
2937
  return toSourceBabelTS(node.type);
2826
2938
  case 'LastTypeNode':
2827
2939
  return toSourceBabelTS(node.qualifier);
2940
+ case 'TSTypeQuery':
2941
+ var argument = toSourceBabelTS(node.exprName);
2942
+ return {
2943
+ type: 'typeof',
2944
+ argument: argument
2945
+ };
2828
2946
  default:
2829
2947
  console.warn('toSourceBabelTS> unhandled type', node.type, node);
2830
2948
  debugger;
package/index.mjs CHANGED
@@ -81,6 +81,13 @@ function expandTypeDepFree(type) {
81
81
  elements: elements.map(expandTypeDepFree)
82
82
  };
83
83
  }
84
+ if (type.startsWith('typeof ')) {
85
+ const argument = expandTypeDepFree(type.substring(7));
86
+ return {
87
+ type: 'typeof',
88
+ argument
89
+ };
90
+ }
84
91
  if (type === 'object' || type === 'Object') {
85
92
  return {
86
93
  type: 'object',
@@ -270,6 +277,9 @@ function parseJSDocTypedef(typedefs, warn, comment, expandType) {
270
277
  } else {
271
278
  warn("not an extensible type", lastTypedef);
272
279
  }
280
+ } else if (line.startsWith('@callback')) {
281
+ const name = line.substring(9).trim();
282
+ typedefs[name] = 'Function';
273
283
  }
274
284
  }
275
285
  }
@@ -363,7 +373,7 @@ class Stringifier {
363
373
  return '';
364
374
  }
365
375
  this.lastCommentBlockIndex = loc.start.index;
366
- const {
376
+ let {
367
377
  spaces
368
378
  } = this;
369
379
  let out = '';
@@ -371,6 +381,14 @@ class Stringifier {
371
381
  if (dedicatedLine) {
372
382
  out += spaces;
373
383
  }
384
+ const multiLine = loc.start.line !== loc.end.line;
385
+ if (multiLine) {
386
+ var _this$parents$at;
387
+ if (((_this$parents$at = this.parents.at(-2)) == null ? void 0 : _this$parents$at.type) === 'AssignmentExpression') {
388
+ spaces += ' ';
389
+ }
390
+ out += '\n' + spaces;
391
+ }
374
392
  out += '/*';
375
393
  if (value.includes('\n')) {
376
394
  value = trimEndSpaces(value.replace(/^\s*\*/gm, '*')).split('\n').filter(_ => _.length).map((line, i) => (i ? spaces + ' ' : '') + line).join('\n');
@@ -648,6 +666,23 @@ class Stringifier {
648
666
  out += ';';
649
667
  return out;
650
668
  }
669
+ ClassPrivateProperty(node) {
670
+ const {
671
+ static: static_,
672
+ key,
673
+ value
674
+ } = node;
675
+ let out = this.spaces;
676
+ if (static_) {
677
+ out += 'static ';
678
+ }
679
+ out += this.toSource(key);
680
+ if (value) {
681
+ out += ' = ' + this.toSource(value);
682
+ }
683
+ out += ';';
684
+ return out;
685
+ }
651
686
  ContinueStatement(node) {
652
687
  const {
653
688
  label
@@ -692,12 +727,21 @@ class Stringifier {
692
727
  params
693
728
  } = node;
694
729
  let out = '';
730
+ if (node.leadingComments) {
731
+ if (this.parentType === 'AssignmentExpression') {
732
+ this.numSpaces++;
733
+ }
734
+ out += '\n' + this.spaces;
735
+ }
695
736
  if (async) {
696
737
  out += 'async ';
697
738
  }
698
739
  const star = generator ? '*' : '';
699
740
  out += 'function' + star + ' ' + this.toSource(id) + this.FunctionDeclarationParams(params);
700
741
  out += this.toSource(body);
742
+ if (node.leadingComments && this.parentType === 'AssignmentExpression') {
743
+ this.numSpaces--;
744
+ }
701
745
  return out;
702
746
  }
703
747
  ArrowFunctionExpression(node) {
@@ -1095,23 +1139,48 @@ class Stringifier {
1095
1139
  ExportAllDeclaration(node) {
1096
1140
  return `export * from ${node.source.extra.raw};`;
1097
1141
  }
1142
+ ExportNamespaceSpecifier(node) {
1143
+ const {
1144
+ exported
1145
+ } = node;
1146
+ return '* as ' + this.toSource(exported);
1147
+ }
1098
1148
  ExportNamedDeclaration(node) {
1099
1149
  const {
1100
1150
  declaration,
1101
1151
  source,
1102
- specifiers
1152
+ specifiers,
1153
+ loc
1103
1154
  } = node;
1104
1155
  let out = this.spaces;
1105
1156
  if (specifiers.length) {
1106
- out += 'export {\n';
1107
- out += this.mapToSource(specifiers).map(_ => ` ${this.spaces}${_}`).join(',\n');
1108
- out += '\n';
1109
- out += this.spaces;
1110
- out += '}';
1111
- if (source) {
1112
- out += " from " + this.toSource(source);
1157
+ if (!source) {
1158
+ console.warn("ExportNamedDeclaration> no source given");
1159
+ }
1160
+ if (specifiers.length === 1 && specifiers[0].type === 'ExportNamespaceSpecifier') {
1161
+ out += 'export ';
1162
+ out += this.toSource(specifiers[0]);
1163
+ out += ' from ';
1164
+ out += this.toSource(source);
1165
+ out += ";";
1166
+ } else {
1167
+ const sameLine = loc.start.line === loc.end.line;
1168
+ if (sameLine) {
1169
+ out += 'export {';
1170
+ out += this.mapToSource(specifiers).join(', ');
1171
+ out += '}';
1172
+ } else {
1173
+ out += 'export {\n';
1174
+ out += this.mapToSource(specifiers).map(_ => ` ${this.spaces}${_}`).join(',\n');
1175
+ out += '\n';
1176
+ out += this.spaces;
1177
+ out += '}';
1178
+ }
1179
+ if (source) {
1180
+ out += " from " + this.toSource(source);
1181
+ }
1182
+ out += ";\n";
1113
1183
  }
1114
- out += ";\n";
1115
1184
  } else if (declaration) {
1116
1185
  out += 'export ' + this.toSource(declaration);
1117
1186
  } else {
@@ -1649,9 +1718,6 @@ class Asserter extends Stringifier {
1649
1718
  i--;
1650
1719
  while (i >= 0) {
1651
1720
  parent = parents[i];
1652
- if (parent.type === 'CallExpression') {
1653
- break;
1654
- }
1655
1721
  if (nodeIsFunction(parent)) {
1656
1722
  break;
1657
1723
  }
@@ -1667,26 +1733,38 @@ class Asserter extends Stringifier {
1667
1733
  }
1668
1734
  console.warn(...args);
1669
1735
  }
1670
- getJSDoc(node) {
1671
- if (node.type === 'BlockStatement') {
1672
- node = this.parent;
1736
+ getLeadingCommentsNodeForFunctionExpression(node) {
1737
+ const {
1738
+ parents
1739
+ } = this;
1740
+ let i = parents.findLastIndex(_ => _ === node);
1741
+ let parent = parents[i];
1742
+ if (parent.leadingComments) {
1743
+ return parent;
1673
1744
  }
1674
- if (node.type === 'FunctionExpression') {
1675
- if (node.leadingComments) {
1676
- this.warn("Case of FunctionExpression containing its own leadingComments is not handled");
1677
- return;
1745
+ i--;
1746
+ while (i >= 0) {
1747
+ parent = parents[i];
1748
+ if (nodeIsFunction(parent)) {
1749
+ break;
1678
1750
  }
1679
- node = this.findParentOfType(node, 'ExpressionStatement');
1680
- if (!node) {
1681
- node = this.parents.findLast(_ => _.type === 'VariableDeclaration');
1682
- if (!node) {
1683
- return;
1684
- }
1751
+ if (parent.leadingComments) {
1752
+ return parent;
1685
1753
  }
1754
+ i--;
1755
+ }
1756
+ }
1757
+ getJSDoc(node) {
1758
+ if (node.type === 'BlockStatement') {
1759
+ node = this.parent;
1686
1760
  }
1687
1761
  let {
1688
1762
  leadingComments
1689
1763
  } = node;
1764
+ if (node.type === 'FunctionExpression') {
1765
+ const tmp = this.getLeadingCommentsNodeForFunctionExpression(node);
1766
+ leadingComments = tmp == null ? void 0 : tmp.leadingComments;
1767
+ }
1690
1768
  if (!leadingComments) {
1691
1769
  if (node.type === 'FunctionDeclaration') {
1692
1770
  const exportNamedDeclaration = this.findParentOfType(node, 'ExportNamedDeclaration');
@@ -1712,6 +1790,9 @@ class Asserter extends Stringifier {
1712
1790
  [paramName]: parseJSDocSetter(lastComment.value, this.expandType)
1713
1791
  };
1714
1792
  }
1793
+ if (lastComment.value.includes('@ignoreRTI')) {
1794
+ return;
1795
+ }
1715
1796
  return parseJSDoc(lastComment.value, this.expandType);
1716
1797
  }
1717
1798
  }
@@ -1898,6 +1979,23 @@ class Asserter extends Stringifier {
1898
1979
  }
1899
1980
  return out;
1900
1981
  }
1982
+ getNameForFunctionExpression(node) {
1983
+ const objectProperty = this.findParentOfType(node, 'ObjectProperty');
1984
+ if (objectProperty) {
1985
+ return this.toSource(objectProperty.key);
1986
+ }
1987
+ const expressionStatement = this.findParentOfType(node, 'ExpressionStatement');
1988
+ if (expressionStatement) {
1989
+ const {
1990
+ left
1991
+ } = expressionStatement.expression;
1992
+ if (left) {
1993
+ return this.toSource(left);
1994
+ }
1995
+ console.warn("Asserter#getNameForFunctionExpression> expression without left");
1996
+ }
1997
+ return 'unnamed function expression';
1998
+ }
1901
1999
  getName(node) {
1902
2000
  const toSource = this.toSource.bind(this);
1903
2001
  if (node.type === 'BlockStatement') {
@@ -1924,11 +2022,7 @@ class Asserter extends Stringifier {
1924
2022
  if (id) {
1925
2023
  return toSource(id);
1926
2024
  }
1927
- const expressionStatement = this.findParentOfType(node, 'ExpressionStatement');
1928
- if (!expressionStatement) {
1929
- return 'unnamed function expression';
1930
- }
1931
- return toSource(expressionStatement.expression.left);
2025
+ return this.getNameForFunctionExpression(node);
1932
2026
  case 'ArrowFunctionExpression':
1933
2027
  const parent = this.findParentOfType(node, 'VariableDeclarator');
1934
2028
  if (parent) {
@@ -2098,6 +2192,9 @@ function toSourceTS(node) {
2098
2192
  ConditionalType,
2099
2193
  IndexedAccessType,
2100
2194
  RestType,
2195
+ TypeQuery,
2196
+ TypeOperator,
2197
+ KeyOfKeyword,
2101
2198
  ConstructorType
2102
2199
  } = ts.SyntaxKind;
2103
2200
  switch (node.kind) {
@@ -2173,6 +2270,21 @@ function toSourceTS(node) {
2173
2270
  };
2174
2271
  }
2175
2272
  return ret;
2273
+ case TypeQuery:
2274
+ const argument = toSourceTS(node.exprName);
2275
+ return {
2276
+ type: 'typeof',
2277
+ argument
2278
+ };
2279
+ case TypeOperator:
2280
+ if (node.operator === KeyOfKeyword) {
2281
+ const _argument = toSourceTS(node.type);
2282
+ return {
2283
+ type: 'keyof',
2284
+ argument: _argument
2285
+ };
2286
+ }
2287
+ console.warn("unimplemented TypeOperator", node);
2176
2288
  case TypeReference:
2177
2289
  {
2178
2290
  if ((typeName.text === 'Object' || typeName.text === 'Record') && (typeArguments == null ? void 0 : typeArguments.length) === 2) {
@@ -2453,6 +2565,12 @@ function toSourceBabelTS(node) {
2453
2565
  return toSourceBabelTS(node.type);
2454
2566
  case 'LastTypeNode':
2455
2567
  return toSourceBabelTS(node.qualifier);
2568
+ case 'TSTypeQuery':
2569
+ const argument = toSourceBabelTS(node.exprName);
2570
+ return {
2571
+ type: 'typeof',
2572
+ argument
2573
+ };
2456
2574
  default:
2457
2575
  console.warn('toSourceBabelTS> unhandled type', node.type, node);
2458
2576
  debugger;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtime-type-inspector/transpiler",
3
- "version": "2.1.4",
3
+ "version": "2.2.1",
4
4
  "description": "Validating JSDoc types at runtime for high-quality types - Trust is good, control is better.",
5
5
  "main": "index.cjs",
6
6
  "module": "index.mjs",
@@ -18,7 +18,7 @@
18
18
  "homepage": "https://github.com/kungfooman/RuntimeTypeInspector.js#readme",
19
19
  "dependencies": {
20
20
  "@babel/core": "^7.2.0",
21
- "@runtime-type-inspector/runtime": "^2.0.10",
21
+ "@runtime-type-inspector/runtime": "^2.1.0",
22
22
  "typescript": "^5.1.6"
23
23
  },
24
24
  "files": [