Граф коммитов

7 Коммитов

Автор SHA1 Сообщение Дата
Timothee Guerin 675e6d480d
Fix type argument tmlanguage (#4089)
Fix #3524
2024-08-08 21:42:27 +00:00
Timothee Guerin 7900f29d65
Classify single using (#3767)
fix  #3629
2024-07-08 17:27:00 +00:00
Timothee Guerin 7912e8c9c7
Add support for `@prop` doc comment tag to describe model properties (#3527)
closes https://github.com/microsoft/typespec/issues/2211

[Playground
example](https://cadlplayground.z22.web.core.windows.net/prs/3527/?c=LyoqCiAqIE1vZGVsIGRvY8QNQHByb3AgYSBByg1iIELKDWMgQ8oNZCBECiAqLwptxUJCYXNlIHsKICBhOiBzdHJpbmc7CiAgYsoNCiAgLyoqIEV4cGxpY2l0IHZpYcR3IGNvbW1lbnTESiAgY80wQGRvYygiZcwyxBMiKSBkyih9CgrnAMvoAKRvdmVycmlkZcVfaGVyZesAp0NoaWxk5QCoLi4u5AC0xEE%3D&e=%40typespec%2Fopenapi3&options=%7B%7D)
2024-06-11 19:22:43 +00:00
Timothee Guerin 7ec17161b7
Value world, object, tuple literals, const (#3022)
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>
2024-05-08 20:06:28 +00:00
Timothee Guerin ce9c567e5b
Improve TM language for enums, unions and escaped identifiers (#3069)
resolves https://github.com/microsoft/typespec/issues/3070
The tm language wasn't correctly defining the syntax for escaped
identifiers

```
`North West`
```


Enums and unions syntax was also not very accurate and didn't tokenize
everything correctly


## Example of issue before


![image](https://github.com/microsoft/typespec/assets/1031227/ee60f4fe-5eef-4f86-baa5-1cc96b665526)

## After

![image](https://github.com/microsoft/typespec/assets/1031227/38405f18-0fa4-44ba-82f6-594bcd4fcebf)
2024-03-27 10:12:29 -07:00
Timothee Guerin e0dfe6f5d0
Grammar: Fix comments in template params not tokenized (#3018)
fix #3017

---------

Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2024-03-22 02:53:07 +00:00
Timothee Guerin afd377242e
Include tmlanguage computed file in repo as we'll need it for github linguist (#2872)
To register a tm language on github linguist we need to publish our
grammar.
Instructions
https://github.com/github-linguist/linguist/blob/master/CONTRIBUTING.md#adding-a-language
2024-02-09 04:07:46 +00:00