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

Enum Typed variables coming in as strings #581

Closed
awasser-omnispear opened this issue Mar 31, 2022 · 3 comments
Closed

Enum Typed variables coming in as strings #581

awasser-omnispear opened this issue Mar 31, 2022 · 3 comments

Comments

@awasser-omnispear
Copy link

I am using TypeScript and the accountingApi.getReportProfitAndLoss endpoint. The response from of this endpoint has some enum types. RowType being one of them, as seen below.

However, the actual data coming down is not an Enum, it is actually a string. This causes an error when comparing the value of the data to the enum.
I.E. row.rowType == RowType.Header will always be false.
row.rowType == 'Header' will work, but TypeScript indicates this as an error.
I should note, that this only affects the TypeScript typing. JavaScript works perfectly fine, since it does not enforce any types.

A workaround would be to use row.rowType.toString() == 'Header'. Since rowType comes in as a string anyway, calling toString() effectively does nothing, except to satisfy TypeScript.

I would like to see the row.rowType == RowType.Header code fragment work correctly for TypeScript users.

@mbyrne00
Copy link

mbyrne00 commented Jun 3, 2022

Hrmmm ... another typescript issue. Just heads up that the dates are also incorrectly typed, format incorrectly documented and plain wrong and the team have simply ignored this blatant bug since Feb 2021. #487 (comment)

@sangeet-joy-tw
Copy link
Contributor

Hey @awasser-omnispear

I have tried asserting rowType - row.rowType == RowType.Header for accountingApi.getReportProfitAndLoss() method in our xero-node sample app and it is working fine for me.

Xero-node version I am using is - 8.0.0

Here is the sample code on my local -

image

Could you please try with the latest xero-node version and let us know if you are still facing this issue ?

@awasser-omnispear
Copy link
Author

awasser-omnispear commented Jul 9, 2024

Glad to see it working! Due to technical reasons, we cannot upgrade Xero-node yet in our project, but we're working on it. I won't be able to test in a reasonable amount of time.

I'm happy to close this issue with your example alone. This issue is over 2 years old, and if I encounter another problem, I'll just create fresh issue.

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

No branches or pull requests

3 participants