Skip to content

Support decimal type in RLC#2170

Merged
MaryGao merged 7 commits intoAzure:mainfrom
MaryGao:support-decimal-type
Dec 20, 2023
Merged

Support decimal type in RLC#2170
MaryGao merged 7 commits intoAzure:mainfrom
MaryGao:support-decimal-type

Conversation

@MaryGao
Copy link
Copy Markdown
Member

@MaryGao MaryGao commented Dec 19, 2023

fixes #2157
Support decimal in RLC - map the decimal to number in JS directly, and will

  • add below comments in generated code
Please note the field was supposed to be a decimal but JavaScript does not have a native 'BigDecimal' data type.
So it was converted to a number instead. It is recommended to use a third-party library like 'decimal.js' to handle 
any calculations.
  • report a warning
Please note the decimal type will be converted to number. If you strongly care about precision you can use @encode to encode it as a string for the property - {your prop name}.

Encoding as string is still pending typespec discussion microsoft/typespec#2762.

@MaryGao MaryGao marked this pull request as ready for review December 19, 2023 09:30
Comment thread packages/typespec-ts/test/integration/scalar.spec.ts Outdated
@MaryGao MaryGao requested review from lirenhe and xirzec December 19, 2023 09:55
Comment thread packages/typespec-ts/src/utils/modelUtils.ts Outdated
Copy link
Copy Markdown
Member

@joheredi joheredi left a comment

Choose a reason for hiding this comment

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

Left a couple of comments but look fine otherwise

@MaryGao MaryGao merged commit 1bd68af into Azure:main Dec 20, 2023
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.

Support decimal type from typespec

4 participants