-
Notifications
You must be signed in to change notification settings - Fork 240
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
Value world, object, tuple literals, const #3022
Value world, object, tuple literals, const #3022
Conversation
All changed packages have been documented.
Show changes
|
You can try these changes at https://cadlplayground.z22.web.core.windows.net/prs/3022/ Check the website changes at https://tspwebsitepr.z22.web.core.windows.net/prs/3022/ |
Co-authored-by: Brian Terlson <[email protected]>
Co-authored-by: Brian Terlson <[email protected]>
args: readonly Type[]; | ||
/** @internal */ map: Map<TemplateParameter, Type>; | ||
getMappedType(type: TemplateParameter): Type | Value | IndeterminateEntity; | ||
args: readonly (Type | Value | IndeterminateEntity)[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timotheeguerin that's interesting, do we take this as breaking change?
Our code would fail compile due to this change. https://dev.azure.com/azure-sdk/public/_build/results?buildId=3820465&view=logs&j=830f3c89-f0a6-536d-4907-0d5f5b592ed8&t=e0231fa7-1c00-50a2-4f06-772d628498b2&l=209
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
widen the union in output is a breaking, in this case that union type is being used by us, it's an output, therefore it's a breaking. as inspired by the point 6 of @xirzec 's summary of what should be considered as breaking Azure/azure-sdk-for-js#22983 (comment)
resolves #2046 Playround
Add the new syntax for object literals using
#{
. For this first version an object literal can only contain other object literal and other literals(string, number, boolean))Values axioms
alias
always produces a type. If you attempt to alias a value, you get an error.Breaking change
Removal of the
ValueType
replacement withMixedConstraint
This shouldn't affect anyone as you were only exposed to this if you digged into the template parameter and looked at the constraint
Deprecation
Using a tuple instead of a tuple literal
Using a model expression instead of an object literal
This technically didn't work before(different from above where tuple was used as a value) but allow this will allow us to convert most of our decorators to use
![Kapture 2024-03-18 at 19 31 32](https://private-user-images.githubusercontent.com/1031227/313894210-f6d69ab4-139e-4b01-95a3-f376b8515d1c.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1MDcwNTMsIm5iZiI6MTczOTUwNjc1MywicGF0aCI6Ii8xMDMxMjI3LzMxMzg5NDIxMC1mNmQ2OWFiNC0xMzllLTRiMDEtOTVhMy1mMzc2Yjg1MTVkMWMuZ2lmP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTRUMDQxOTEzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YjI3ZTM5YjlmZDc2ZTJiM2U5ZmJmZDdhMzBlNmE4OTUyNWQ3MDU3ZmU5M2YzNjUwN2JjYjYyNjhjNjBjMGY1YyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.PnAlSQPMgmBAalKB8bZBtTKJ4sd4c63frCyLO-tRHcw)
valueof
without being breakingOld decorator marshalling
If a library had a decorator with
valueof
one of those typesnumeric
,int64
,uint64
,integer
,float
,decimal
,decimal128
,null
it used to marshall those as JSnumber
andNullType
fornull
. With the introduction of values we have a new marshalling logic which will marshall those numeric types asNumeric
and the others will remain numbers.null
will also get marshalled asnull
.For now this is an opt-in behavior with a warning on decorators not opt-in having a parameter with a constraint from the list above.
Example:
Will now emit a deprecated warning because
value
is of typevalueof string
which would marshall toNumeric
under the new logic but asnumber
previously.To opt-in you can add the following to your library