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

72 Коммитов

Автор SHA1 Сообщение Дата
Timothee Guerin a336c93709
Update prettier config to format trailing commas to `all` (Default) (#4457)
fix #2159 
Long standing backlog issue that was split from an upgrade of prettier
as it created too much diff. Finally doing it
2024-09-16 20:20:57 +00:00
Timothee Guerin 3d14d7c2c9
Bump dependencies - Sep 2024 (#4424)
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
2024-09-13 15:50:22 +00:00
Christopher Radek 0be9e8f22b
TypeSpec 0.59 - September Release branch (#4386)
Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
2024-09-10 22:45:59 +00:00
Timothee Guerin 75e773cfa8
Add new way to define decorator implementation with `$decorators` export (#4139)
fix [#3719](https://github.com/microsoft/typespec/issues/3719)
2024-08-12 19:16:21 +00:00
Michelle dda9db6f08
Update emitter docs to include configuration examples (#4112)
For a TypeSpec beginner, it may be difficult to understand how to
configure or format tspconfig.yaml to tweak the different options
available. Adding a basic example should help folks get started.
2024-08-08 13:48:26 +00:00
Christopher Radek 1455928d25
TypeSpec 0.59 - August 2024 Release branch (#4120)
Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
2024-08-08 04:54:25 +00:00
Timothee Guerin 49004b60d5
Update dependencies (#3948)
New pr from this branch as it had some weird docusaurus issue not
reproducable anywhere else and just changing branch fixes it somehow
https://github.com/microsoft/typespec/pull/3934
Notable:
- vitest: 2.x
- prettier update that does a minor formatting change by adding
parentheses in some ternary expression
2024-07-23 21:02:34 +00:00
Timothee Guerin 6aad4a795f
Add `const` template parameter to get the precise lib type (#3933)
Without that there is some loss of information
2024-07-22 22:25:40 +00:00
Timothee Guerin af65ce9220
Bump versions for release 0.57 (#3855) 2024-07-17 00:10:54 +00:00
Timothee Guerin f3c2c9b67c
Dependency updates July 2024 (#3718)
Notable: Typescript 5.5
2024-07-01 21:42:11 +00:00
Allen Zhang 9c701cc272
TypeSpec 0.57 - June 2024 Release publish branch (#3578)
Co-authored-by: Timothee Guerin <tiguerin@microsoft.com>
2024-06-13 21:47:55 +00:00
Will Temple c9fe5a0ce3
[protobuf] Handle cross-package references correctly in some buggy cases. (#3561)
Closes #3534
Closes #3556 

This PR adds cross-package resolution in some cases where it was
missing.

In the case of operation inputs, missing effective model type
calculation was causing some input types not to be resolved to external
packages.

In the case of map value types, the calculation of the right hand side
type did not correctly account for the possibility of the type being in
another package, and it now uses the same machinery as other type
references to instrument imports and cross-package references.

The existing scenario test has been extended to prevent regressions and
also extended to test arrays for good measure, though those were working
as expected.

---------

Co-authored-by: Will Temple <will@wtemple.net>
Co-authored-by: Timothee Guerin <tiguerin@microsoft.com>
2024-06-11 21:25:17 +00:00
Vitalii Kryvenko d14b0d7b63
Preserve leading whitespace in fenced blocks in doc comments (#3399)
Fixes #3370.

This also updates the generated documentation and typescript code to fix
lack of indentation on existing fenced blocks in this repo.

---------

Co-authored-by: Timothee Guerin <timothee.guerin@outlook.com>
2024-05-20 19:57:31 +00:00
Timothee Guerin e316792dcd
Update dependencies - May 2024 (#3401) 2024-05-20 16:31:39 +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 dec504364c
Bump versions for 0.56.0 release (#3298) 2024-05-08 00:34:05 +00:00
Timothee Guerin cb6fea49d7
Split libraries from emitters (#3258)
Makes it easier to discover our emitters

also cleanup a reference to non existent json-rpc emitter
2024-05-02 16:54:35 +00:00
Timothee Guerin 5757fd16e4
Include `type` in generated extern dec (#3250)
This allows us to use `verbatimModuleSyntax: true`
2024-04-29 20:23:34 +00:00
Timothee Guerin d290c17b5e
Update dependencies - april 2024 (#3169)
Notable: 
- vitest `1.5.0` which solves some issues with running in the extension
- remove `sinon` from compiler which is not needed anymore as vitest
provide spies built-in
2024-04-15 10:24:38 -07:00
Timothee Guerin 35f5c90343
Migrate to eslint flat config (#3123)
resolve https://github.com/microsoft/typespec/issues/3121
same change in typespec-azure
https://github.com/Azure/typespec-azure/pull/620

## Single top level config
This makes it a little nicer to run as you know get the absolute path
for errors
No need to have the hacky rushstack dependency to allow using the same
shared config.

## Able to lint the projects that are outside of the pnpm workspace
<img width="1054" alt="image"
src="https://github.com/microsoft/typespec/assets/1031227/f88691d9-1bf2-4140-ba2b-533207b15f9d">


## Eslint 9 -no yet

eslint 9 was just released firday which makes this config the new
default however it does include breaking changes and not all our plugins
have updated
2024-04-08 09:58:19 -07:00
Timothee Guerin 0c1b96be47
Ci improvements (#3099)
- Use corepack to install pnpm: Faster and respect the pnpm version set
in package.json instead of having another place to keep up to date
- dependency cache
- upgrade to new code coverage task
- Move all consitency check to independent github action workflow(Makes
it easier to see which one failed immediately without having to open
devops and dig into the steps)
2024-04-03 16:19:59 -07:00
Timothee Guerin 2f53533d94
Bump versions for release 0.55.0 - april 2024 (#3096) 2024-04-02 14:55:47 -07:00
Timothee Guerin 0dea649cd7
Update dependencies to resolve vulnerabilities and license issue (#3081)
- Remove unused rollup-plugin-dts dep that had problematic license
- Update dependencies to fix vulnerabilies
2024-03-29 21:22:06 +00:00
Timothee Guerin 077db13c8d
Generate TypeScript decorator signatures from `extern dec` (#2122)
Note this is added to `tspd` which is not published yet so this can be
iterated over without any issues.

Adds a decorator signature generator. Generates 2 files:
- `<namespace>.ts` : Contains the decorator signatures that can be
imported and when declaring the decorators functions
- `<namespace>.ts-test.ts`: Contains some test using typescript type
system to make sure the package does reexport the right `$<name>` for
each decorator

---------

Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
2024-03-19 23:08:59 +00:00
Timothee Guerin 4199f83575
Upgrade dependencies march 2024 (#3027)
General update of all dependencies, notable
- typescript 5.4
- vitest 1.4
2024-03-18 10:52:06 -07:00
Timothee Guerin 7312314bcb
Remove old message burried in changelog (#2989) 2024-03-05 16:05:57 -08:00
Timothee Guerin 9881002f1c
Bump versions for release march 2024 (#2988) 2024-03-05 15:31:47 -08:00
Timothee Guerin 02ed01e79b
Improved ref docs for model (#2951)
fix https://github.com/Azure/typespec-azure-pr/issues/3861
fix #2232
Generate docs for model properties and reference models within the same
package
<img width="1213" alt="image"
src="https://github.com/microsoft/typespec/assets/1031227/ae7eccd0-97d8-401e-b07f-3375c7b41446">
2024-02-29 07:21:13 -08:00
Timothee Guerin 7452fe9a57
Update dependencies - feb 2024 (#2900)
General dependency updates, notable:
- typescript 5.3
- chronus 0.6.0 (BREAKING  THE CHANGELOG FORMAT)
2024-02-08 15:14:01 -08:00
Timothee Guerin 173c0de73c
Merge hotfix back into main (#2899) 2024-02-08 11:37:38 -08:00
Timothee Guerin ad74773b53
Bump version for February release (#2890) 2024-02-06 16:14:38 -08:00
Will Temple a3d6acfa67
[protobuf] Add support for expanding template names. (#2861)
There is a bug in the protobuf emitter currently where we use the base
name of a template when emitting corresponding models. This patch adds
support for extracting an instance name, using friendlyName if it is
available or otherwise constructing a name by prepending the name of the
argument types to the template's name.

Closes #2857

---------

Co-authored-by: Will Temple <will@wtemple.net>
2024-02-01 18:23:32 +00:00
Mark Cowlishaw 345cd594da
Prepare Publish for January Release (#2816) 2024-01-24 11:14:23 -08:00
Timothee Guerin 55ea44250d
Vitest improvements: vitest-ui, watch mode for deps, debug config (#2791)
Add vitest ui package and `test:ui` command to popup the vitest UI
https://vitest.dev/guide/ui

Import the common vitest config from the workspace so each package
doesn't need to define all of it.
Added `watchExclude: []` to the common config to preven vitest from
excluding dist and node_modules folder which is required so it can auto
rerun the test on when a dependency (monorepo dep) rebuilds

Added debug config to debug the current test. As the vitest extensions
is quite unreliable this should help
2024-01-22 09:56:55 -08:00
Timothee Guerin 9c7bf80187
Migrate test framework to vitest (#2769)
Get rid of mocha and upgrade to vitest which is a more modern
alternative providing, watch, direct typescript compilation out of the
box, expect library and more.

Advantage over mocha:
- Much better cli
  -  watch mode
  - better diff
- Better extension:
  -  tree organization for files too (not everything flattened)
- update in real time the test(no more need to refresh manually to
discover where are the tests)
  - just a little buggy
- Compiles typescript directly
- provides more expectation apis(like jest)

Cons over mocha: 
- Slower(about 2x) but that means we don't need to build the test as
part of build which would speed up that part(not as much as is lost)

Todo: 
- typespec-azure migration
2024-01-02 11:40:29 -08:00
Will Temple aae7166f0a
Rename template parameters for clarity and consistency (#2726)
This is in preparation for merging named template argument
instantiation.

---------

Co-authored-by: Will Temple <will@wtemple.net>
2023-12-18 13:44:37 -05:00
Timothee Guerin 9f15ba5502
General dependency upgrades (#2753)
Major:
- Typescript 5.3
- Vite 5
- Rollup 4
2023-12-13 21:01:13 +00:00
Mark Cowlishaw e52a32c76a
Prepare Publish for December release (#2740) 2023-12-06 12:43:01 -08:00
Timothee Guerin c749b1148f
Split libraries from standard library (#2674)
Having the std and other libraries merged together always made it harder

---------

Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2023-11-21 20:13:40 +00:00
Mark Cowlishaw 6d69297a05
Prepare typespec publish for November Release (#2646) 2023-11-07 16:56:19 -08:00
Alexander Batishchev 2353586552
Added maxDiffSize to Mocha configuration (#2593)
Copying changes from https://github.com/Azure/typespec-azure/pull/3731/

Note: I added the following files as they were missing but the
corresponding `.mocharc.yaml` files already exist:

- packages/protobuf/mocha.reporter.config.json
- packages/samples/mocha.reporter.config.json
- packages/typespec-vscode/mocha.reporter.config.json
2023-10-19 22:37:26 +00:00
Mark Cowlishaw e76223066e
Prepare typespec publish (#2567) 2023-10-11 17:38:29 -07:00
Will Temple eeff7961f1
[protobuf] Preserve documentation comments (#2283)
This change preserves `@doc` comments when emitting protobuf schemas. We
convert the protobuf documentation comments into a format that will feel
familiar to Protobuf developers and that Protobuf tooling will be able
to parse. I've never used a documentation generator with Protobuf, but I
made sure it works with pseudomuto/protoc-gen-doc, as that seems to be
the most recommended community project for doc generation. I also made
sure that the protoc Java compiler emits readable documentation based on
the example spec in the tests.

The rules for comments are:
- On _field_ and _enum variant_ declarations, we will emit a trailing
`//` comment if the length of the line overall will not be longer than
80 characters.
- In all other cases, we will emit a block of `//` comments aligned with
the beginning of the declaration.

Closes #1878

---------

Co-authored-by: Will Temple <will@wtemple.net>
Co-authored-by: Timothee Guerin <tiguerin@microsoft.com>
2023-10-03 17:37:50 -07:00
Timothee Guerin 61ba17d2d2
General dependencies update september 2023 (#2445)
fix https://github.com/Azure/typespec-azure/issues/3602

Notable change:
- yaml update removes the uncessary escaping of openapi paths
2023-09-21 13:34:11 -07:00
Timothee Guerin 246bda233b
Fix formatting of union (#2441)
fix [#2382](https://github.com/microsoft/typespec/issues/2382)

---------

Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
2023-09-20 20:43:30 +00:00
Mark Cowlishaw aa4d05ac5b
Backmerge 2023 09 19 hotfixes (#2444)
Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
Co-authored-by: adam-joffe <58192966+adam-joffe@users.noreply.github.com>
2023-09-19 15:13:38 -07:00
Mark Cowlishaw c9a2751618
Prepare typespec publish for September release (#2409) 2023-09-12 16:38:24 -07:00
Timothee Guerin bb3d2df9b4
Report errors on node id when possible (#2296)
fix #2084

When a diagnostic target a type/node instead of reporting the error on
the whole type spamming the IDE or terminal with a large warning/error
we only highlight that type id instead.

This is the behavior we can see in typescript/eslint. When the
error/warning is meant to target an interface/function, etc. it will
only highlight the name when able.
2023-08-18 19:42:11 +00:00
Timothee Guerin 6d98cd0afb
Merge `--config` hotfix back into main (#2289)
Co-authored-by: Mingzhe Huang <archerzz@users.noreply.github.com>
2023-08-10 14:29:32 -07:00
Will Temple 1b8b27e3d9
[protobuf] Add `omit-unreachable-types` (#2281)
This PR tweaks the way that models are included in output specifications
when they are not referenced by operations and adds an option for
controlling this behavior.

The option is `omit-unreachable-types` after the OpenAPI v3 emitter
which uses the same name, and the behavior in the protobuf emitter is
similar. If a message is expliclty decorated with `@message` or is
referenced direclty or indirectly by an operation/method, it will be
emitted. Otherwise, it will be emitted if (1) it is a direct child of a
`package` namespace AND (2) ALL of its fields are annotated with
`@field` AND (3) the `omit-unreachable-types` option is not set to true.

Closes #1879

---------

Co-authored-by: Will Temple <will@wtemple.net>
2023-08-10 16:12:21 -04:00