Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show type warning if you provide allow and deny to detectBot #1502

Closed
davidmytton opened this issue Sep 4, 2024 · 6 comments
Closed

Show type warning if you provide allow and deny to detectBot #1502

davidmytton opened this issue Sep 4, 2024 · 6 comments

Comments

@davidmytton
Copy link
Contributor

We throw if you provide both allow and deny configs for detectBot, but it would be helpful to show a type warning as well:

image
file:///Users/david/Code/arcjet-js/arcjet/index.js:384
            throw new Error("Both allow and deny cannot be provided to detectBot");
                  ^

Error: Both allow and deny cannot be provided to detectBot
    at detectBot (file:///Users/david/Code/arcjet-js/arcjet/index.js:384:19)
    at file:///Users/david/Code/arcjet-js/examples/express-bots/index.js:17:5
    at ModuleJob.run (node:internal/modules/esm/module_job:234:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)
@blaine-arcjet
Copy link
Contributor

This is weird because there should be a type warning 🤔

@davidmytton
Copy link
Contributor Author

Ah maybe because it's a js example, not ts?

@blaine-arcjet
Copy link
Contributor

Correct, there's no type checking in JS

@blaine-arcjet
Copy link
Contributor

You can see that I needed to use @ts-expect-error when defining them both in the tests.

@davidmytton
Copy link
Contributor Author

I didn't even look at the extension, just assumed it was TS...I never write pure JS 😅

@blaine-arcjet
Copy link
Contributor

Any example that runs in just Node without an explicit CLI tool to build the application is pure JS because otherwise adding a build step with all the dependencies takes away from the purity of the example. Perhaps we need to spend time on #72 so we can have consolidated examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants