Notable:
- Typescript 5.6: iterator functions and more
- typescript-eslint 8: new rules, breaking change to some other, found a
few bugs/test not actually testing
- eslint 9: new rules
- removed deprecation/deprecation plugin as typescript eslint has rule
for it now(and updated) many places where it wasn't reporting correctly
resolves#2046
[Playround](https://cadlplayground.z22.web.core.windows.net/prs/3022/)
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
1. `alias` always produces a type. If you attempt to alias a value, you
get an error.
2. A string template produces a string template type if all
substitutions are types, and a value if all substitutions are numeric,
boolean, or string values. A mixture of types and values is an error.
3. The string literal syntax always results in a string literal type
4. A string literal type may be passed as a string value when the
signature expects a value. When the signature expects either a string
literal type or a string value, it is passed as a string value.
5. A string template type can be passed as a string value when all its
substitutions are string literal types.
## Breaking change
### Removal of the `ValueType` replacement with `MixedConstraint`
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
- ✅ still work
- emit a warning
<img width="1013" alt="image"
src="https://github.com/microsoft/typespec/assets/1031227/ab05359a-5ed9-4a27-a8d1-f40d1e21766f">
- provide a codefix
<img width="312" alt="image"
src="https://github.com/microsoft/typespec/assets/1031227/5ef93bdf-665f-4445-a6b2-62475efe8c16">
## 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 `valueof` without being breaking
![Kapture 2024-03-18 at 19 31
32](https://github.com/microsoft/typespec/assets/1031227/f6d69ab4-139e-4b01-95a3-f376b8515d1c)
## Old decorator marshalling
If a library had a decorator with `valueof` one of those types
`numeric`, `int64`, `uint64`, `integer`, `float`, `decimal`,
`decimal128`, `null` it used to marshall those as JS `number` and
`NullType` for `null`. With the introduction of values we have a new
marshalling logic which will marshall those numeric types as `Numeric`
and the others will remain numbers. `null` will also get marshalled as
`null`.
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:
```
extern dec multipleOf(target: numeric | Reflection.ModelProperty, value: valueof numeric);
```
Will now emit a deprecated warning because `value` is of type `valueof
string` which would marshall to `Numeric` under the new logic but as
`number` previously.
To opt-in you can add the following to your library
```ts
export const $flags = defineModuleFlags({
decoratorArgMarshalling: "value",
});
```
---------
Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
Same pr in typespec-azure
https://github.com/Azure/typespec-azure/pull/3641
Migrate to use the `types` entry under `exports` instead of hte legacy
typesVersions. This was a leftover to when es modules where not
completely supported in typescript and using typesVersions was a
workaround.
This makes a union declaration like:
```
union Foo { A, B }
```
behave roughly equivalently to the union expression `A | B`.
Fixes#45.
---------
Co-authored-by: Timothee Guerin <tiguerin@microsoft.com>
- Add support for `pre to` and `pre from` projections that can run before
children are projected and return never to delete or a different type.
- It is an error to mutate anything pre-projections but this is not
currently enforced by the compiler. We had a note to document this, but
projections are still experimental and undocumented, so documeting it
here.
- Add support for `#enummember`, `#unionvariant`, and `#modelproperty`
projections.
- Use these features in versioning library to fix issues that led to emitter
crashes with versioned resource types.
- Fix issues with incompatible versioniing verification:
- Bogus error asking to annotate a template definition when passing a
versioned template argument.
- Failure to validate versioned types in tuples or unions.
- Failure to validate template arguments/array element type in operation
return type.
- Add access to the extends list of an interface via
`Interface.sourceInterfaces`. This was a requested feature for next
sprint, but ended up helping to get the validation fixed so it is done
here.
* Escape identifier with backtick
* revert binder.test.ts
* backticked
* add test case
* test case
* rush change
* Remove StringLiteral for model property keys and enum
* clean todo
* rush change
* support the same escape characters in backticked identifier
* limit where string literal can be used
* address comment
* support non-ASCII characters in backticked identifiers
* fix identifier printer
* rush format
* improve changelog
* remove workaround in Versions enum
* fix bug
* regen samples
* Update packages/compiler/core/scanner.ts
Co-authored-by: Nick Guerrera <nicholg@microsoft.com>
* add test case for completion
* fix renaming
* type signatures
* printable type signatures
* allow the same escapeCharaters in quotes and backticks
* optimize parseIdentifier
* escape special characters when printing
* test case
---------
Co-authored-by: Nick Guerrera <nicholg@microsoft.com>