Uncaught SyntaxError: A class may only have one constructor
travismfrank opened this issue · comments
When building with hayd/alpine-deno:1.9.0, I am receiving the following SyntaxError:
error: Uncaught SyntaxError: A class may only have one constructor
//deno-lint-ignore camelcase
~~~~~~~~~~~
at <anonymous> (https://deno.land/x/postgres@v0.11.1/query/query.ts:217:31)
This behavior was not present with 1.8.2; perhaps stemming from useDefineForClassFields set to true
?
Hi @TravisFrankMTG, by any chance are you bundling your code?
I am bundling my client code, but I don't bundle this module. I do cache my dependencies, including this module, with deno cache --unstable deps.ts
before running my server with deno run --allow-env --allow-read --allow-net --unstable main.tsx
. The error is thrown when I run the server, not when I cache the deps.
Update - after switching my frontend from TS -> JS, I am no longer encountering this error. Curious why this change would result in this behavior, as I cannot tell why changes in the client code would affect my server when compiling, but heh, there ya go. @Soremwar feel free to close, but would love to hear what prompted you to ask about bundling. Thanks!
@TravisFrankMTG Sorry for the slow response, and the reason I asked if you were bundling your code is because there was a chance this was related to Deno's bundling, I have constructor overloads in my code, and those should be removed when transpiling from TS to JS, but your error made me think that they were not
I am bundling my client code, but I don't bundle this module
Can you elaborate further on this? If you are bundling code that uses this library, it will be included in the final result
A quick note on fixing this; the problem seems to disappear when you switch to e.g. debian-deno. I wonder if this is related to denoland/deno_docker#113.
https://github.com/denodrivers/postgres/blob/master/query/query.ts#L216
https://github.com/denodrivers/postgres/blob/master/query/query.ts#L218
https://github.com/denodrivers/postgres/blob/master/query/query.ts#L219
The error points to these codes,Multiple constructors exist
@eeve Those are constructor overloads, they are legal syntax