Closed srepollock closed 4 years ago
It's a deno bug. See https://github.com/asos-craigmorten/opine/issues/42#issuecomment-658159231
var myUrl = new URL(new URL("http://www.google.com/cookies"));
// TS2345 [ERROR]: Argument of type 'URL' is not assignable to parameter of type 'string'.
var myPathname = myUrl.pathname;
These 2 lines of code work in FF(latest), node 12 and chrome ( 83.0.4103.116 ) but do not work in deno:
deno --version
deno 1.2.0
v8 8.5.216
typescript 3.9.2
Thanks for raising this @srepollock!
Having followed the issue on GitHub and Discord, and reading the changelog I still managed to overlook this 🤦
Relevant issues / PRs:
It's annoying that it deviates from what browsers / node allow, but the Deno team are aiming to write to WHATWG spec.
Should be simple enough to fix, we just need to cast to string as the URL
constructor no longer accepts a URL
as the first parameter.
Did theses PRs make it into the 1.2.0?
@Bidek56 It looks like it was from commit https://github.com/denoland/deno/commit/5c43131be1a36671fd564b82709e11dff66488f3
Hello, I'm experiencing this issue using Opine 0.25.0
on Deno 1.4.2
? Thanks
Hey @KaKi87 can you provide a reproduceable example and the exact errors your are getting on the console? 😄
Update:
I've just created a file:
// example.ts
import { opine } from "https://deno.land/x/opine@0.25.0/mod.ts";
const app = opine();
app.use((req, res) => {
res.send("Hello World");
});
app.listen(3000, () => console.log("Starting server on port 3000"));
Based on the readme, and ran with:
deno run --allow-net --allow-read --reload example.ts
And worked fine for me for Deno 1.4.2
:
$ deno --version
deno 1.4.2
v8 8.7.75
typescript 4.0.3
So will need more information in order to diagnose! If you could open a new issue that would be appreciated.
Well, turns out I was confused while reading the dependency tree from the deno info
command, yes it is the exact same error, but no it is not comming from opine.
Actually, it is coming from argon2, and if I would have cared to properly read the README, I would have figured out from the beginning that it was not supposed to be compatible with Deno versions after 1.2.3
...
Now I have to figure out how am I going to hash passwords.
Thanks, anyway, and I'm truly sorry for the time you wasted because of me.
Issue
Setup:
Details
When running my program:
with the command:
deno run mod.ts
I get the following error:
I've traced the issue to these two lines:
https://github.com/asos-craigmorten/opine/blob/2295ba25be8320e0a3adfb5fe9d53477b02d1650/src/middleware/serveStatic.ts#L227
https://github.com/asos-craigmorten/opine/blob/2295ba25be8320e0a3adfb5fe9d53477b02d1650/src/utils/parseUrl.ts#L70
I believe this is an error in type and should be addressed. I cannot run my program at this time. Let me know if you agree this is the issue and I can try to implement a fix.