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

Issue with property named get inside classes #296

Open
yspreen opened this issue Mar 25, 2024 · 4 comments
Open

Issue with property named get inside classes #296

yspreen opened this issue Mar 25, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@yspreen
Copy link

yspreen commented Mar 25, 2024

Express and Drizzle both have classes with property methods called get. It seems to be fine if defined like

get(/* args */) {
  /* method */
}

but this line in drizzle: https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/sqlite-core/query-builders/delete.ts#L251

get: ReturnType<this['prepare']>['get'] = (placeholderValues) => {
	return this._prepare().get(placeholderValues);
};

causes issues in LLRT when compiled with TS and bundled with rollup.js:

invalid property name

because the compiled result is

get = (e) => this._prepare().get(e);
@richarddavison
Copy link
Contributor

richarddavison commented Mar 25, 2024

Hi @yspreen, thanks for the report. Do you have a minimum reproducible js file?

I can't reproduce this:

class Examle{
  get(){
      return "hello world")
  }
}

console.log(new Example().get())

@yspreen
Copy link
Author

yspreen commented Mar 26, 2024

~/Downloads/llrt ./test.js
SyntaxError: invalid property name
    at ./test.js:2:6
class TestClass {
  get = () => console.log("get");
}

new TestClass().get();

@yspreen
Copy link
Author

yspreen commented Mar 26, 2024

as mentioned above, it only breaks if you set it to an anonymous method. not if defining get() {}

@richarddavison richarddavison added the bug Something isn't working label Mar 26, 2024
@richarddavison
Copy link
Contributor

I've located the issue and submitted a patch to downstream QuickJS engine. The catch is that we're not up to date on the latest version. However, we can (and already do) apply patches independently of the engine:
bellard/quickjs#258

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants