How to type URLs?
Hi, not sure if this is an ArkType or ArkEnv specific question but I'm using ArkEnv for strongly typed env vars. Everything in my config is typed except for my database url, which is currently typed as 'any'.
If I remove the type() wrapper, then I get the following lint error:
Type '"string.url"' is not assignable to type '"Reference to submodule 'string.url' must specify an alias"'
Here is the config.ts from my Bun project:
Is there a way to type my URL as just a web standard URL? Or maybe type it as a string with a base url of 'libsql://'?2 Replies
this sounds like an issue with arkenv maybe @yamcodes (arkenv.js.org) could take a look?
Thanks @ArkDavid. @yamcodes (arkenv.js.org) was able to assist me on ArkEnv's GitHub issue #374
Posting the response here for posterity:
yamcodes: "@callthecapital What do you have for compilerOptions.moduleResolution and compilerOptions.module in your tsconfig.json?
Please make sure that your compilerOptions.moduleResolution is set to "bundler", "node16" or "nodenext".If it's unset, consider setting it or using compilerOptions.module that is one of Preserve, Node16, Node18, Node20 or NodeNext. Read more: https://www.typescriptlang.org/tsconfig/#moduleResolution
#378 is the likely cause here."
--
callthecapital: "Hi, my compilerOptions.moduleResolution was originally set to "ES2022" and my compilerOptions.module was set to "node".
Once I updated moduleResolution to "bundler" and module to "preserve", I was able to remove the type() wrapper and just have TURSO_DATABASE_URL: "string.url", which is typed as a url!
Thank you so much!"