@runtime-type-inspector/transpiler 3.2.7 → 3.3.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 +20 -12
  2. package/index.mjs +22 -14
  3. package/package.json +2 -2
package/index.cjs CHANGED
@@ -3423,23 +3423,31 @@
3423
3423
  if (node.type === 'BlockStatement') {
3424
3424
  node = this.parent;
3425
3425
  }
3426
- if (node.type === 'ClassMethod' && node.kind === 'set') {
3427
- var paramName = this.getNameOfParam(node.params[0]);
3428
- if (node.params.length !== 1) {
3429
- this.warn("getJSDoc> setters require exactly one argument");
3430
- }
3431
- var setterType = parseJSDocSetter(comment, this.expandType);
3432
- if (!setterType) {
3426
+ if (node.type === 'ClassMethod') {
3427
+ if (node.kind === 'get') {
3428
+ // JSDoc on a getter is just some documentation.
3433
3429
  return;
3430
+ } else if (node.kind === 'set') {
3431
+ if (node.params.length !== 1) {
3432
+ this.warn("getJSDoc> setters require exactly one argument");
3433
+ }
3434
+ var setterType = parseJSDocSetter(comment, this.expandType);
3435
+ if (!setterType) {
3436
+ return;
3437
+ }
3438
+ var paramName = this.getNameOfParam(node.params[0]);
3439
+ var _params = _defineProperty({}, paramName, setterType);
3440
+ return {
3441
+ templates: undefined,
3442
+ params: _params
3443
+ };
3434
3444
  }
3435
- var _params = _defineProperty({}, paramName, setterType);
3436
- return {
3437
- templates: undefined,
3438
- params: _params
3439
- };
3440
3445
  }
3441
3446
  var templates = parseJSDocTemplates(comment);
3442
3447
  var params = parseJSDoc(comment, this.expandType);
3448
+ if (!templates && !params) {
3449
+ return;
3450
+ }
3443
3451
  return {
3444
3452
  templates: templates,
3445
3453
  params: params
package/index.mjs CHANGED
@@ -3108,25 +3108,33 @@ class Asserter extends Stringifier {
3108
3108
  if (node.type === 'BlockStatement') {
3109
3109
  node = this.parent;
3110
3110
  }
3111
- if (node.type === 'ClassMethod' && node.kind === 'set') {
3112
- const paramName = this.getNameOfParam(node.params[0]);
3113
- if (node.params.length !== 1) {
3114
- this.warn("getJSDoc> setters require exactly one argument");
3115
- }
3116
- const setterType = parseJSDocSetter(comment, this.expandType);
3117
- if (!setterType) {
3111
+ if (node.type === 'ClassMethod') {
3112
+ if (node.kind === 'get') {
3113
+ // JSDoc on a getter is just some documentation.
3118
3114
  return;
3115
+ } else if (node.kind === 'set') {
3116
+ if (node.params.length !== 1) {
3117
+ this.warn("getJSDoc> setters require exactly one argument");
3118
+ }
3119
+ const setterType = parseJSDocSetter(comment, this.expandType);
3120
+ if (!setterType) {
3121
+ return;
3122
+ }
3123
+ const paramName = this.getNameOfParam(node.params[0]);
3124
+ const _params = {
3125
+ [paramName]: setterType
3126
+ };
3127
+ return {
3128
+ templates: undefined,
3129
+ params: _params
3130
+ };
3119
3131
  }
3120
- const _params = {
3121
- [paramName]: setterType
3122
- };
3123
- return {
3124
- templates: undefined,
3125
- params: _params
3126
- };
3127
3132
  }
3128
3133
  const templates = parseJSDocTemplates(comment);
3129
3134
  const params = parseJSDoc(comment, this.expandType);
3135
+ if (!templates && !params) {
3136
+ return;
3137
+ }
3130
3138
  return {
3131
3139
  templates,
3132
3140
  params
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.2.7",
4
+ "version": "3.3.1",
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.2.7",
22
+ "@runtime-type-inspector/runtime": "^3.3.1",
23
23
  "typescript": "^5.1.6"
24
24
  },
25
25
  "files": [