Skip to content

Commit d5047d6

Browse files
committed
docs(semver): add JSDoc @typedef for ParsedVersion interface
Signed-off-by: leocavalcante <leo@cavalcante.dev>
1 parent 561596f commit d5047d6

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/semver.mjs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,19 @@
55
* supporting common range patterns like ^, ~, >=, >, <=, <, and exact matching.
66
*/
77

8+
/**
9+
* A parsed semantic version with numeric components.
10+
* @typedef {Object} ParsedVersion
11+
* @property {number} major - The major version number (breaking changes)
12+
* @property {number} minor - The minor version number (new features, backwards compatible)
13+
* @property {number} patch - The patch version number (bug fixes, backwards compatible)
14+
*/
15+
816
/**
917
* Parses a semver version string into its numeric components.
1018
*
1119
* @param {string} version - The version string (e.g., "1.2.3")
12-
* @returns {{ major: number, minor: number, patch: number } | null} Parsed version or null if invalid
20+
* @returns {ParsedVersion | null} Parsed version or null if invalid
1321
* @throws {TypeError} If version is not a string
1422
*/
1523
export function parseVersion(version) {
@@ -56,8 +64,8 @@ function validateParsedVersion(value, paramName) {
5664
/**
5765
* Compares two parsed version objects.
5866
*
59-
* @param {{ major: number, minor: number, patch: number }} a - First version
60-
* @param {{ major: number, minor: number, patch: number }} b - Second version
67+
* @param {ParsedVersion} a - First version
68+
* @param {ParsedVersion} b - Second version
6169
* @returns {number} -1 if a < b, 0 if a == b, 1 if a > b
6270
* @throws {TypeError} If a or b is not a valid ParsedVersion object
6371
*/

0 commit comments

Comments
 (0)