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

const ${localName(method)} can result in a not allowed variable name #18

Closed
Madumo opened this issue Jan 31, 2023 · 1 comment · Fixed by #28
Closed

const ${localName(method)} can result in a not allowed variable name #18

Madumo opened this issue Jan 31, 2023 · 1 comment · Fixed by #28

Comments

@Madumo
Copy link

Madumo commented Jan 31, 2023

I have a case where a service has a "Delete" method. Since the generator will output export const ${localName(method)} = ..., it will output export const delete = ..., which is a reserved keyword in javascript and cannot be used as a variable name in strict mode. This will make typescript compilation fail with no way of ignoring the issue.

While "delete" is the more likely case to happen in this context, all methods named after a reserved word will also generate invalid code as such.

A simple solution could be using PascalCase for the variable declaration, but that would also break any code using this after the upgrade.

What are your thought on this?

In the meantime i'll just automatically patch the file after generation with a sed command.

Thanks a lot by the way, this toolchain is a game changer for us compared to using grpc-web! :)

@dimitropoulos
Copy link
Contributor

You're totally right. This is a problem.

I've added a PR for one solution to this in #19. Would love to hear your feedback on the approach taken.

p.s. thanks for the kind words!

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