Jaguar Zhou
Jaguar Zhou

Reputation: 161

When will an optional property in `chrome.history.HistoryItem` be undefined?

Here is how it is defined in @types/chrome:

    /** An object encapsulating one result of a history query. */
    export interface HistoryItem {
        /** Optional. The number of times the user has navigated to this page by typing in the address. */
        typedCount?: number | undefined;
        /** Optional. The title of the page when it was last loaded. */
        title?: string | undefined;
        /** Optional. The URL navigated to by a user. */
        url?: string | undefined;
        /** Optional. When this page was last loaded, represented in milliseconds since the epoch. */
        lastVisitTime?: number | undefined;
        /** Optional. The number of times the user has navigated to this page. */
        visitCount?: number | undefined;
        /** The unique identifier for the item. */
        id: string;
    }

I don't understand why there are so many optional properties, I've never seen onVisited missing these properties in my actual applications.

I suspect that what onVisited carries is actually Required<chrome.history.HistoryItem>. When are they really optional?

I used indexeddb to record all my history for a day and did not see any records with missing optional properties.

Upvotes: 0

Views: 21

Answers (0)

Related Questions