|
| 1 | +--- |
| 2 | +title: "1.0.0" |
| 3 | +releaseDate: 2025-05-06 |
| 4 | +version: "1.0.0" |
| 5 | +--- |
| 6 | + |
| 7 | +## TypeSpec 1.0 Release |
| 8 | + |
| 9 | +Today, we’re thrilled to announce the general availability of TypeSpec 1.0! This milestone marks the transition of TypeSpec’s core components from release candidate to stable release status. TypeSpec is a Microsoft-built, community-supported project that makes API-first development truly practical by empowering you to define your APIs in a concise, human-readable format and generate all the artifacts you need—from OpenAPI specifications to client libraries and server code scaffolding—from a single source of truth. |
| 10 | + |
| 11 | +[See our blob post](https://typespec.io/blog/typespec-1-0-GA-release/) |
| 12 | + |
| 13 | +## Breaking Changes |
| 14 | + |
| 15 | +### @typespec/http |
| 16 | + |
| 17 | +- [#7230](https://github.com/microsoft/typespec/pull/7230) Changed `@patch` so that it does not apply the "implicit optionality" transform by default anymore. |
| 18 | + |
| 19 | + ```diff lang=tsp |
| 20 | + @patch op update(@body pet: Pet): void; |
| 21 | + ``` |
| 22 | + |
| 23 | + To use JSON Merge-Patch to update resources, replace the body property with an instance of `MergePatchUpdate` as follows: |
| 24 | + |
| 25 | + ```tsp |
| 26 | + @patch op update(@body pet: MergePatchUpdate<Pet>): void; |
| 27 | + ``` |
| 28 | + |
| 29 | + Or, keep the old behavior by explicitly enabling `implicitOptionality` in the `@patch` options: |
| 30 | + |
| 31 | + ```tsp |
| 32 | + @patch(#{ implicitOptionality: true }) op update(@body pet: Pet): void; |
| 33 | + ``` |
| 34 | + |
| 35 | +## Features |
| 36 | + |
| 37 | +### @typespec/compiler |
| 38 | + |
| 39 | +- [#7199](https://github.com/microsoft/typespec/pull/7199) Add "capitalize" string helper to compiler |
| 40 | +- [#7180](https://github.com/microsoft/typespec/pull/7180) Add support for formatting `tspconfig.yaml` with `tsp format` |
| 41 | +- [#7180](https://github.com/microsoft/typespec/pull/7180) `tsp format` only formats files it knows about and ignores other. Allowing a more generic glob pattern `tsp format .` or `tsp format "**/*"` |
| 42 | +- [#5674](https://github.com/microsoft/typespec/pull/5674) [LSP] Update imports when renaming typespec files |
| 43 | +- [#7125](https://github.com/microsoft/typespec/pull/7125) Adds typekits for getting intrinsic types via `$.intrinsic.<type>` |
| 44 | +- [#7204](https://github.com/microsoft/typespec/pull/7204) Update typekits `is*` methods to accept `Entity` instead of just `Type` or `Value` |
| 45 | +- [#7108](https://github.com/microsoft/typespec/pull/7108) Adds support for nesting typekits |
| 46 | +- [#7202](https://github.com/microsoft/typespec/pull/7202) Replaces `$.model.getSpreadType` with `$.model.getIndexType` to better reflect what it actually being returned. `getSpreadType` did not actually return a list of spread types, but the model's indexer type instead. |
| 47 | +- [#7090](https://github.com/microsoft/typespec/pull/7090) Adds TypeKit support for type.inNamespace to check namespace membership |
| 48 | +- [#7167](https://github.com/microsoft/typespec/pull/7167) Adds `$.value.resolve` and `$.type.resolve` typekits, and updated `$.resolve` to return values or types, instead of just types |
| 49 | +- [#7106](https://github.com/microsoft/typespec/pull/7106) Adds `$.type.isAssignableTo`, `$.value.isAssignableTo` and `$.entity.isAssignableTo` typekits. Also registers `$.resolve` typekit |
| 50 | +- [#7193](https://github.com/microsoft/typespec/pull/7193) Typekits have been moved out of experimental and can now be accessed via the `@typespec/compiler/typekit` submodule. |
| 51 | + This also removed the `$.type.getDiscriminator` typekit in favor of the `$.model.getDiscriminatedUnion` and `$.union.getDiscriminatedUnion` |
| 52 | + typkits. |
| 53 | + |
| 54 | + ```diff |
| 55 | + -import { $ } from "@typespec/compiler/experimental/typekit"; |
| 56 | + +import { $ } from "@typespec/compiler/typekit"; |
| 57 | + ``` |
| 58 | + |
| 59 | +- [#7105](https://github.com/microsoft/typespec/pull/7105) Add typekit support for creating a union from an array of children |
| 60 | +- [#7207](https://github.com/microsoft/typespec/pull/7207) Exposed experimental function `isMutableType` as `unsafe_isMutableType`. |
| 61 | +- [#7200](https://github.com/microsoft/typespec/pull/7200) Added an optional `nameTemplate` argument to `@withVisibilityFilter`, allowing the visibility filters to rename models as they are transformed. This template is applied by default in the `Create`, `Read`, `Update`, `Delete`, and `Query` visibility transform templates. This allows for more flexible renaming than simply using the `@friendlyName` decorator, as it will change the primary name of the transformed type, reducing the incidence of naming conflicts. |
| 62 | + |
| 63 | + Cached the result of applying visibility filters to types. If the same visibility filter is applied to the same type with the same configuration, the model instance produced by the visibility filter will be object-identical. This should reduce the incidence of multiple models that are structurally equivalent in visibility filters and conflicts over the name of models. |
| 64 | + |
| 65 | +### @typespec/http |
| 66 | + |
| 67 | +- [#7207](https://github.com/microsoft/typespec/pull/7207) Implemented JSON Merge-Patch wrappers. This allows converting a type to a JSON Merge-Patch compatible update record using the `MergePatchUpdate` and `MergePatchCreateOrUpdate` templates. |
| 68 | + |
| 69 | +### @typespec/openapi3 |
| 70 | + |
| 71 | +- [#7199](https://github.com/microsoft/typespec/pull/7199) Add "capitalize" string helper to compiler |
| 72 | + |
| 73 | +### typespec-vscode |
| 74 | + |
| 75 | +- [#7042](https://github.com/microsoft/typespec/pull/7042) send compile startTime and endTime telemetry |
| 76 | + |
| 77 | +## Bug Fixes |
| 78 | + |
| 79 | +### @typespec/compiler |
| 80 | + |
| 81 | +- [#7183](https://github.com/microsoft/typespec/pull/7183) Fix decorators on model properties getting wrongly called when checking the template declaration in the following cases |
| 82 | + - inside a union expression |
| 83 | + - under an non templated operation under a templated interface |
| 84 | +- [#6938](https://github.com/microsoft/typespec/pull/6938) Fixes template argument resolution when a default template parameter value is resolved by a parent container (e.g. interface) |
| 85 | + For example: |
| 86 | + |
| 87 | + ```tsp |
| 88 | + interface Resource<T> { |
| 89 | + read<U = T>(): U; |
| 90 | + } |
| 91 | +
|
| 92 | + model Foo { |
| 93 | + type: "foo"; |
| 94 | + } |
| 95 | +
|
| 96 | + alias FooResource = Resource<Foo>; |
| 97 | +
|
| 98 | + op readFoo is FooResource.read; |
| 99 | + ``` |
| 100 | + |
| 101 | + The `returnType` for `readFoo` would be model `Foo`. Previously the `returnType` resolved to a `TemplateParameter`. |
| 102 | + |
| 103 | +- [#7153](https://github.com/microsoft/typespec/pull/7153) Fixes handling of nested templates in getPlausibleName |
| 104 | +- [#6883](https://github.com/microsoft/typespec/pull/6883) Realm handle multiple instance of compiler loaded at once |
| 105 | +- [#7222](https://github.com/microsoft/typespec/pull/7222) Remove `version` property on `ServiceOptions` passed to `@service` decorator. That handling of that option was removed in `1.0.0-rc.0` where it was previously deprecated. |
| 106 | + If wanting to specify version in an OpenAPI document use the `@OpenAPI.info` decorator from the `@typespec/openapi` library |
| 107 | +- [#7155](https://github.com/microsoft/typespec/pull/7155) Mark `TemplateParameter` type as an experimental type |
| 108 | +- [#7106](https://github.com/microsoft/typespec/pull/7106) Removes `program.checker.isTypeAssignableTo`. Use one of the following typekits instead: |
| 109 | + - `$(program).type.isAssignableTo` |
| 110 | + - `$(program).value.isAssignableTo` |
| 111 | + - `$(program).entity.isAssignableTo` |
| 112 | +- [#7207](https://github.com/microsoft/typespec/pull/7207) Weakened rules around `@mediaTypeHint` decorator, allowing media type hints with suffixes like "application/merge-patch+json". |
| 113 | +- [#7200](https://github.com/microsoft/typespec/pull/7200) Fixed an error in Model visibility filtering where the indexer of a model was ignored. This prevented the value of Array/Record instances from being transformed correctly, as they now should be. |
| 114 | + |
| 115 | +### @typespec/http |
| 116 | + |
| 117 | +- [#7168](https://github.com/microsoft/typespec/pull/7168) Replace optional param validation requiring use with path expansion and replace with a warning when the resulting url might have a double `/` |
0 commit comments