fingerprintjs / BotD

Bot detection library that runs in the browser. Detects automation tools and frameworks. No server required, runs 100% on the client. MIT license, no usage restrictions.
https://fingerprintjs.github.io/BotD/main/
MIT License
954 stars 77 forks source link

Export BotResult along with BotKind #122

Closed xnerhu closed 1 year ago

xnerhu commented 1 year ago

@Finesse I had to replace const enum BotKind with enum BotKind, because of

dist/botd.d.ts:192:30 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided

Let me know if that's ok and won't have side effects on CDN.

xnerhu commented 1 year ago

another approach would be to use string union instead of enum

xnerhu commented 1 year ago

I'm sure there will be no problems with Open CDN. It handles only the distributive JS code.

dist/botd.d.ts:192:30 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided

TypeScript makes sure the package won't cause problems for users who use --isolatedModules. When an enum is not const, it's available in the JS runtime, which might be handy for JS users.

another approach would be to use string union instead of enum

It's a good option. But only TS users will be able to use the BotKind type.

@Finesse For the sake of consistency I changed const enum to enum in the entire project

Finesse commented 1 year ago

For the sake of consistency I changed const enum to enum in the entire project

@xnerhu Up to you. I see no technical problems.

Generally, the reasons to prefers const enums are:

If you think the consistency is more important, no problem.

xnerhu commented 1 year ago

Thanks for the review, I will merge it now.