Skip to content

Commit 0cb5150

Browse files
committed
Allow - in JSDoc @param RegExp to catch scientific notation
1 parent 81e6301 commit 0cb5150

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src-transpiler/parseJSDoc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {simplifyType} from "./simplifyType.js";
1616
*/
1717
function parseJSDoc(src, expandType = expandTypeDepFree) {
1818
// Parse something like: @param {Object} [kwargs={}] Optional arguments.
19-
const regex = /@param \{(.*?)\} ([\[\]a-zA-Z0-9_$=\{\}\.'" ]+)/g;
19+
const regex = /@param \{(.*?)\} ([\[\]a-zA-Z0-9_$=\-\{\}\.'" ]+)/g;
2020
const matches = [...src.matchAll(regex)];
2121
/** @type {Record<string, ExpandTypeReturnType>} */
2222
const params = Object.create(null);

test/typechecking.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@
7171
"input": "./test/typechecking/good-old-es5-input.mjs",
7272
"output": "./test/typechecking/good-old-es5-output.mjs"
7373
},
74+
{
75+
"input": "./test/typechecking/jsdoc-regexp-default-values-sci-input.mjs",
76+
"output": "./test/typechecking/jsdoc-regexp-default-values-sci-output.mjs"
77+
},
7478
{
7579
"input": "./test/typechecking/keyof-typeof-input.mjs",
7680
"output": "./test/typechecking/keyof-typeof-output.mjs"

0 commit comments

Comments
 (0)