Use @typedef {Object} X

When you write @typedef {Object} ScanResult, you’re telling both JSDoc and TypeScript’s parser that this typedef represents an object type, not just an abstract name. This is important because it makes tools like IDEs, linters, and TypeScript’s JSDoc inference more reliable. It avoids ambiguity, especially in cases where the typedef might later be confused with something like a primitive, union, or function type. The official TypeScript documentation and the JSDoc spec both show this form as the canonical one for object shapes.
This commit is contained in:
Hans Ott 2025-11-01 13:28:11 +01:00
parent 29dd63d1eb
commit 484cbcd960
8 changed files with 9 additions and 9 deletions

View file

@ -4,14 +4,14 @@ import {
} from "../malwareDatabase.js";
/**
* @typedef PackageChange
* @typedef {Object} PackageChange
* @property {string} name
* @property {string} version
* @property {string} type
*/
/**
* @typedef AuditResult
* @typedef {Object} AuditResult
* @property {PackageChange[]} allowedChanges
* @property {(PackageChange & {reason: string})[]} disallowedChanges
* @property {boolean} isAllowed