faisalman / ua-parser-js

"Unmask Your Traffic" - UAParser.js: The Essential Web Development Tool for User-Agent Detection
https://uaparser.dev/
GNU Affero General Public License v3.0
9.28k stars 1.2k forks source link

Type Definition Missing: IBrowser.type #710

Closed shiny closed 8 months ago

shiny commented 8 months ago

Library version 2.0.0-beta.2

Describe the bug When using an extension, such as Bots, the result has an attribute browser.type, but not exists in type IBrowser.

To Reproduce

import { UAParser } from 'ua-parser-js'
import { Bots } from 'ua-parser-js/extensions'

const ua = 'Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Chrome/W.X.Y.Z Safari/537.36'
const parser = new UAParser(ua, Bots)
const browser = parser.getBrowser()

Now browser is

{
  "name": "Googlebot",
  "version": "2.1",
  "major": "2",
  "type": "bot"
}

But IBrowser is

  interface IBrowser extends IData<IBrowser> {
      name?: string;
      version?: string;
      major?: string;
  }

type?: string is missing

Expected behavior

interface IBrowser extends IData<IBrowser> {
    name?: string;
    version?: string;
    major?: string;
    type?: string;
}