ua-parser-js icon indicating copy to clipboard operation
ua-parser-js copied to clipboard

No typing for the sub-modules

Open ChangmoSung opened this issue 1 year ago • 6 comments

Library version v2.0.0-alpha.3

The /enums sub-module (and the rest) don't seem to ship with type declarations, so TypeScript complains when you try to import from them:

Screenshot 2024-07-09 at 12 47 25 PM

It seems that it was resolved in this commit https://github.com/faisalman/ua-parser-js/commit/d6d8ac7cb43d610e54e1e4355da35b0e7ea76a43.

However, types were added for other submodules, but not enums.

Could you add types for enums as well?

ChangmoSung avatar Jul 09 '24 16:07 ChangmoSung

+1 to this, it would be great to be able to use the enums from this package.

hbbrawer-twitch avatar Aug 08 '24 23:08 hbbrawer-twitch

Really odd this isn't caught by a test or something similar. I'll open a PR for this shortly.

mikehuebner avatar Dec 08 '24 23:12 mikehuebner

https://github.com/faisalman/ua-parser-js/pull/772

mikehuebner avatar Dec 09 '24 17:12 mikehuebner

Am I the only one who has still problems with this?

import { Bots } from "ua-parser-js/extensions";
import { isBot } from "ua-parser-js/helpers";

RicardoRB avatar Feb 17 '25 15:02 RicardoRB

Am I the only one who has still problems with this?

import { Bots } from "ua-parser-js/extensions"; import { isBot } from "ua-parser-js/helpers";

We are experiencing the same issue.

BabyDino avatar Mar 11 '25 08:03 BabyDino

This is still not working for me, has anyone actually gotten this to work? import { Browser } from 'ua-parser-js/enums';

error: Cannot find module 'ua-parser-js/enums' or its corresponding type declarations.

Edit: Nevermind I figured it out. I needed to update my moduleResolution in my tsconfig

amcinerney avatar Jun 11 '25 13:06 amcinerney

I think this has been fixed now on @ua-parser-js/pro-enterprise:2.0.3? Working for me at least:

import {
  Browser,
  BrowserType,
  Device,
  OS,
} from "@ua-parser-js/pro-enterprise/enums";

hbbrawer-twitch avatar Jul 28 '25 18:07 hbbrawer-twitch