@runtime-type-inspector/transpiler 3.3.6 → 3.3.7
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/index.cjs +18 -5
- package/index.mjs +18 -5
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -976,10 +976,22 @@
|
|
|
976
976
|
// name: [kwargs={}] The configuration parameters.
|
|
977
977
|
// name: [d = 1.0] Sample spacing
|
|
978
978
|
if (name[0] === '[') {
|
|
979
|
-
//
|
|
980
|
-
var
|
|
979
|
+
// Counting opening/closing brackets for perfect match
|
|
980
|
+
var openCloseCount = 1;
|
|
981
|
+
var i = 1;
|
|
982
|
+
for (; i < name.length; i++) {
|
|
983
|
+
var c = name[i];
|
|
984
|
+
if (c === '[') {
|
|
985
|
+
openCloseCount++;
|
|
986
|
+
} else if (c === ']') {
|
|
987
|
+
openCloseCount--;
|
|
988
|
+
}
|
|
989
|
+
if (openCloseCount === 0) {
|
|
990
|
+
break;
|
|
991
|
+
}
|
|
992
|
+
}
|
|
981
993
|
// Afterwards name will be: d = 1.0
|
|
982
|
-
name = name.substring(1,
|
|
994
|
+
name = name.substring(1, i);
|
|
983
995
|
// mark it for the type:
|
|
984
996
|
optional = true;
|
|
985
997
|
}
|
|
@@ -3686,7 +3698,8 @@
|
|
|
3686
3698
|
}
|
|
3687
3699
|
return 0; // continue
|
|
3688
3700
|
} else if (param.left.type === 'ObjectPattern') {
|
|
3689
|
-
|
|
3701
|
+
// If we have properties from JSDoc, we can create individual type inspections.
|
|
3702
|
+
if (type !== null && type !== void 0 && type.properties && Object.keys(type.properties).length) {
|
|
3690
3703
|
// Add a type assertion for each property of the ObjectPattern
|
|
3691
3704
|
var _iterator2 = _createForOfIteratorHelper(param.left.properties),
|
|
3692
3705
|
_step2;
|
|
@@ -3727,7 +3740,7 @@
|
|
|
3727
3740
|
_iterator2.f();
|
|
3728
3741
|
}
|
|
3729
3742
|
return 0; // continue
|
|
3730
|
-
} else
|
|
3743
|
+
} else {
|
|
3731
3744
|
// The case when we have an ObjectPattern with a @typedef
|
|
3732
3745
|
name = "arguments[".concat(paramIndex, "]");
|
|
3733
3746
|
}
|
package/index.mjs
CHANGED
|
@@ -756,10 +756,22 @@ function parseJSDoc(src, expandType = expandTypeDepFree) {
|
|
|
756
756
|
// name: [kwargs={}] The configuration parameters.
|
|
757
757
|
// name: [d = 1.0] Sample spacing
|
|
758
758
|
if (name[0] === '[') {
|
|
759
|
-
//
|
|
760
|
-
|
|
759
|
+
// Counting opening/closing brackets for perfect match
|
|
760
|
+
let openCloseCount = 1;
|
|
761
|
+
let i = 1;
|
|
762
|
+
for (; i < name.length; i++) {
|
|
763
|
+
const c = name[i];
|
|
764
|
+
if (c === '[') {
|
|
765
|
+
openCloseCount++;
|
|
766
|
+
} else if (c === ']') {
|
|
767
|
+
openCloseCount--;
|
|
768
|
+
}
|
|
769
|
+
if (openCloseCount === 0) {
|
|
770
|
+
break;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
761
773
|
// Afterwards name will be: d = 1.0
|
|
762
|
-
name = name.substring(1,
|
|
774
|
+
name = name.substring(1, i);
|
|
763
775
|
// mark it for the type:
|
|
764
776
|
optional = true;
|
|
765
777
|
}
|
|
@@ -3366,7 +3378,8 @@ class Asserter extends Stringifier {
|
|
|
3366
3378
|
}
|
|
3367
3379
|
continue;
|
|
3368
3380
|
} else if (param.left.type === 'ObjectPattern') {
|
|
3369
|
-
|
|
3381
|
+
// If we have properties from JSDoc, we can create individual type inspections.
|
|
3382
|
+
if (type != null && type.properties && Object.keys(type.properties).length) {
|
|
3370
3383
|
// Add a type assertion for each property of the ObjectPattern
|
|
3371
3384
|
for (const property of param.left.properties) {
|
|
3372
3385
|
if (property.type !== 'ObjectProperty') {
|
|
@@ -3398,7 +3411,7 @@ class Asserter extends Stringifier {
|
|
|
3398
3411
|
out += `${spaces} youCanAddABreakpointHere();\n${spaces}}\n`;
|
|
3399
3412
|
}
|
|
3400
3413
|
continue;
|
|
3401
|
-
} else
|
|
3414
|
+
} else {
|
|
3402
3415
|
// The case when we have an ObjectPattern with a @typedef
|
|
3403
3416
|
name = `arguments[${paramIndex}]`;
|
|
3404
3417
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"bin": "bin.js",
|
|
3
3
|
"name": "@runtime-type-inspector/transpiler",
|
|
4
|
-
"version": "3.3.
|
|
4
|
+
"version": "3.3.7",
|
|
5
5
|
"description": "Validating JSDoc types at runtime for high-quality types - Trust is good, control is better.",
|
|
6
6
|
"main": "index.cjs",
|
|
7
7
|
"module": "index.mjs",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"homepage": "https://github.com/kungfooman/RuntimeTypeInspector.js#readme",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@babel/parser": "^7.23.0",
|
|
22
|
-
"@runtime-type-inspector/runtime": "^3.3.
|
|
22
|
+
"@runtime-type-inspector/runtime": "^3.3.7",
|
|
23
23
|
"typescript": "^5.1.6"
|
|
24
24
|
},
|
|
25
25
|
"files": [
|