0.66 - March 2025
Notable changes
Section titled “Notable changes”New Discriminated union with @discriminated
Section titled “New Discriminated union with @discriminated”In order to simplify and provide a more intuitive discriminated union experience, we have introduced a new @discriminated decorator.
This decorators allows you to define a discriminated union that will use the variant names as the discriminator values.
The decorator allows customizing the serialization of the union(by default using an envelop object)
@discriminatedunion Pet { cat: Cat, dog: Dog,}Serialize as
{ "kind": "cat", "value": { "name": "Whiskers", "meow": true }},{ "kind": "dog", "value": { "name": "Rex", "bark": false }}New tsp compile progress indicator
Section titled “New tsp compile progress indicator”$ tsp compile .TypeSpec compiler v0.65.3
✔ Compiling⠙ @typespec/openapi3$ tsp compile .TypeSpec compiler v0.65.3
✔ Compiling✔ @typespec/openapi3
Compilation completed successfully.Breaking Changes
Section titled “Breaking Changes”@typespec/openapi3
Section titled “@typespec/openapi3”- #6182 Using
{service-name}intspconfig.yamlwill always interpolate the current service name.{service-name-if-multiple}can be used to get the previous behavior
Deprecations
Section titled “Deprecations”@typespec/compiler
Section titled “@typespec/compiler”-
#6059 Deprecate use of
@discriminatoron union. Migrate to@discriminated@discriminator("type")@discriminated(#{envelope: "none", discriminatorPropertyName: "type"})union Pet; -
#6088 Deprecate use of string-based visibility modifiers using warnings.
String-based visibilities can be replaced as follows:
"create","read","update","delete", and"query"can be replaced withLifecycle.Create,Lifecycle.Read,Lifecycle.Update,Lifecycle.Delete, andLifecycle.Queryrespectively.@visibility("none")can be replaced with@invisible(Lifecycle).
For example:
@visibility("create", "read")example: string;can be replaced with:
@visibility(Lifecycle.Create, Lifecycle.Read)example: string;@visibility("none")example: string;can be replaced with:
@invisible(Lifecycle)example: string;Additionally,
@parameterVisibilitywith no arguments is deprecated.@parameterVisibility@patchop example(@bodyRoot resource: Resource): Resource;The effect of
@parameterVisibilityis to disable effective PATCH optionality. If you wish to disable effective PATCH optionality in@typespec/http, preventing it from treating all properties of the request body as effectively optional, you can now do so explicitly:@patch(#{ implicitOptionality: false })op example(@bodyRoot resource: Resource): Resource; -
#6108 Migrate
@servicedecorator options to take in a value@service({title: "My service"})@service(#{title: "My service"})
@typespec/http
Section titled “@typespec/http”-
#6130 Updates
@headerdecorator to accept values and adds theexplodeoption. Note that using the model expression syntax to pass in arguments, or using theformatfield, are now deprecated.op example1(@header({ name: "ETag" }) etag: string@header(#{ name: "ETag" }) etag: string): void;op example2(@header({ format: "csv" }) list: string[]@header list: string[]): void;
@typespec/openapi
Section titled “@typespec/openapi”-
#6078 Updates the
@extensiondecorator with 3 changes:- Removes the extension name starts with
x-constraint. - Adds support for passing in values to emit raw data.
- Adds a deprecation warning for passing in types. Passed in types will emit Open API schemas in a future release.
Scalar literals (e.g. string, boolean, number values) are automatically treated as values. Model or tuple expression usage needs to be converted to values to retain current behavior in future releases.
@extension("x-obj", { foo: true })@extension("x-obj", #{ foo: true })@extension("x-tuple", [ "foo" ])@extension("x-tuple", #[ "foo" ])model Foo {} - Removes the extension name starts with
-
#6108 Migrate
@infodecorator to expect a value@info({ version: "1.0.0" })@info(#{ version: "1.0.0" })@info({@info(#{termsOfService: "http://example.com/terms/",contact: {contact: #{name: "API Support",url: "http://www.example.com/support",email: "support@example.com"},})
Features
Section titled “Features”@typespec/compiler
Section titled “@typespec/compiler”-
#5483 Add autocomplete of model properties for union type
-
#5458 Add codefix for for various triple quoted string syntax issues
-
#6082 Introduced
list-filesflag to log all emitted files. -
#6082 Added a progress indicator to show the current stage of tsp compilation process.
-
#6059 Add new
@discriminateddecorator to represent discriminated union with implicit envelopes -
#5494 Report unused template parameters in language server
-
#6045 Redesign and simplification of
tsp init -
#5996 Add Typekits to support EFV2
-
#5986 Tsp init template with both config and emitters merge in tspconfig.yaml
-
#6047
--versionshows if tsp is running from the standalone version -
#5453 Report unused
usingin language server -
#6164 Renamed package
@typespec/http-server-javascriptto@typespec/http-server-js.
@typespec/http
Section titled “@typespec/http”- #5996 Emitter Framework V2
@typespec/openapi3
Section titled “@typespec/openapi3”- #6059 Add support for new
@discriminatedunions - #5994 Adds
seal-object-schemasemitter option to automatically set additionalProperties/unevaluatedProperties to{ not: {} }wherever possible - #5961 Updates JsonSchema and Open API 3.1 emitters to use unevaluatedProperties instead of additionalProperties, and updates Open API 3 emitters to match JsonSchema behavior of treating
Record<never>as settingadditionalProperties: { not: {} } - #6130 updates openapi3 to respect
@headersexplodeoption and use value syntax - #6157 Shared operations operationId can now be set if they all share the same value provided by
@operationId - #6006 Expose core library types in API surface.
@typespec/html-program-viewer
Section titled “@typespec/html-program-viewer”- #5996 Emitter Framework V2
@typespec/json-schema
Section titled “@typespec/json-schema”- #5994 Adds
seal-object-schemasemitter option to automatically set additionalProperties/unevaluatedProperties to{ not: {} }wherever possible - #5961 Updates JsonSchema and Open API 3.1 emitters to use unevaluatedProperties instead of additionalProperties, and updates Open API 3 emitters to match JsonSchema behavior of treating
Record<never>as settingadditionalProperties: { not: {} }
typespec-vs
Section titled “typespec-vs”- #5968 Support intellisense for tsconfig.yaml in visual studio
typespec-vscode
Section titled “typespec-vscode”- #6014 Add “Import TypeSpec from OpenApi3” menu item into explorer context menu
- #6164 Renamed package
@typespec/http-server-javascriptto@typespec/http-server-js.
Bug Fixes
Section titled “Bug Fixes”@typespec/compiler
Section titled “@typespec/compiler”- #4926 Augmenting an expression will now report an error instead of silently failing to apply.
- #5937 Fix: StringTemplate type not supported in typespecValueToJson
- #6204 Fix
@examplereporting assignability error when using mix metadata(http) models - #6125 Fix tmlanguage syntax highlighting when using decorator before escaped identifier
- #6192 Fix
tsp infocrash - #6203 Fix mutator not mutating sourceModel(s)
@typespec/openapi3
Section titled “@typespec/openapi3”- #5901 Fix:
@typespec/openapi3/invalid-component-fixed-field-keyshow on incorrect target
typespec-vscode
Section titled “typespec-vscode”- #6137 Fix code snippet for union in typespec-vscode