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

Fix build error for special characters #64

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

rmagur1203
Copy link

#63

  • Use ElementAccessExpression when accessing properties.
  • When doing destructuring assignment, wrap the key in a StringLiteral.
  • Normalizes characters that cannot be used in identifier.

@GoogleFeud
Copy link
Owner

GoogleFeud commented Aug 24, 2024

Thank you for the PR! It looks like you've changed the line endings of the file though, could you please use the line endings defined in the .prettierrc.json file? Also, could you please use the dev branch, because that's where changes go before they're published

@jerzygangi
Copy link

@rmagur1203 Are you still planning to make the edits required on this PR?

@rmagur1203 rmagur1203 changed the base branch from main to dev November 11, 2024 13:23
@rmagur1203
Copy link
Author

In prettierrc, the end of line is set to crlf, but in reality it seems to be set to lf.
Changed it to lf and modified it to merge into the dev branch.

@@ -171,7 +174,7 @@ export function _not(exp: ts.Expression): ts.Expression {
export function _access(exp: ts.Expression, key: string | number | ts.Expression): ts.Expression {
if (typeof key === "string") {
if (isInt(key)) return factory.createElementAccessExpression(exp, ts.factory.createNumericLiteral(key));
return ts.factory.createPropertyAccessExpression(exp, key);
return ts.factory.createElementAccessExpression(exp, ts.factory.createStringLiteral(key));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this always create element access expressions? It would be nice to create element access expressions only when necessary because otherwise code turns to this:

// We don't want this
errs["push"]("Expected value to be an object");

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sure looks good to use createElementAccessExpression only when there are special characters, but since it is only used to access data and is a built file, it doesn't seem to matter much.

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

Successfully merging this pull request may close these issues.

3 participants