Skip to content

Fixed incorrect error on intersected number and string types#786

Merged
Perryvw merged 6 commits into
masterfrom
bugfix/number-intersection-fix
Jan 2, 2020
Merged

Fixed incorrect error on intersected number and string types#786
Perryvw merged 6 commits into
masterfrom
bugfix/number-intersection-fix

Conversation

@Perryvw

@Perryvw Perryvw commented Jan 2, 2020

Copy link
Copy Markdown
Member

Fixes #782

Comment thread test/unit/builtins/string.spec.ts Outdated
Comment thread test/unit/builtins/numbers.spec.ts Outdated
Comment thread test/unit/builtins/string.spec.ts Outdated
Comment thread src/transformation/builtins/index.ts
Comment thread src/LuaPrinter.ts Outdated
const name = this.printIdentifier(expression.name);

chunks.push(prefix, ":", name, "(");
const prefix = this.printExpression(expression.prefixExpression);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How about something like that to remove parenthesizing duplication?

Suggested change
const prefix = this.printExpression(expression.prefixExpression);
const prefix = this.printExpression(lua.isStringLiteral(expression.prefixExpression) ? expression.prefixExpression : lua.createParenthesizedExpression(expression.prefixExpression));;

Also, what about "foo".bar?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Should not be affected by this PR, I'd prefer to keep that for the full parenthesis to printer change.

Comment thread src/transformation/builtins/array.ts Outdated
@Perryvw Perryvw merged commit 295d907 into master Jan 2, 2020
@Perryvw Perryvw deleted the bugfix/number-intersection-fix branch January 2, 2020 21:38
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.

Methods on types intersected with number cannot be used

2 participants