December 2022
New features
Decorator signature help
With the decorator signature extern dec
added in previous release and the doc comment support added in this version the IDE is able to provide a signature help for decorators
New scalar
type
This release introduce a new scalar type meant to represent what were previously models with no properties actually representing an scalar value.
Emitter options interpolation and standardization
Emitter options are not able to interpolate other values. See details
Breaking changes
TypeSpec
Api
Compiler
Moved TypeSpec intrinsic types to a new Type scalar
A new type has been introduced to TypeSpec in order to differentiate scalar from structured models types. Those new types can be declared using scalar
and can extend another scalar using extends
.
Change to TypeSpec intrinsic models
All of TypeSpec intrinsic models have been updated to be scalar
types instead of model
. In most cases this shouldnât affect a spec but if you are defining a custom model that is
one of the intrinsic types youâll have to update it
Before
After
Migration script
The following script can be used to automatically migrate previous usages.
Change to Compiler API
Removed:
getIntrinsicModelName
: Check it is a std type withprogram.checker.isStdType(type)
and then use thetype.name
otherwise look fortype.baseScalar
isIntrinsic
: Check it is a std type withprogram.checker.isStdType(type)
or just remove the check if goal was to omit intrinsic types from models.
Migration:
- Add a new switch to handle the new
scalar
type - To resolve a scalar type, check if its a std type using
program.checker.isStdType(type)
- If yes, do the same behavior has before with
getIntrinsicModelName
- If not, call
scalar.baseScalar
and repeat step 2.
API
- Change to onEmit
signature
The signature of onEmit
has been updated to accommodate for changes to the emitter options
Before
Now
Access properties
Before | Now |
---|---|
program | context.program |
options | context.options |
options["output-dir"] | context.emitterOutputDir See details |
[TypeSpec] [Api] Emitter option output-dir
renamed to emitter-output-dir
The option has been renamed for all emitters as emitter-output-dir
is now managed in the compiler
Before
Now
Change to api
Before
Now
API > @typespec/compiler
Multiple services per typespec specs are now allowed making a service accessor obsolete.
The following functions have been deprecated
and replaced with
Other changes to the service resolution:
- Title wonât be defaulted to
(title)
- Version wonât be defaulted to
0000-00-00
- Service namespace wonât be defaulted to global namespace
Before | To add support for multi serviceF |
---|---|
getServiceNamespace(program) | listServices(program) to get all services |
getServiceNamespaceString(program) | getNamespaceName(service.type) is where service is getService(program, serviceNamespace) |
getServiceTitle(program) | service.title where service is getService(program, serviceNamespace) |
getServiceVersion(program) | service.version where service is getService(program, serviceNamespace) |
TypeSpec
Directives can no longer be placed in certain contexts.
For example, this is no longer valid:
And will now result in an error âCannot place directive on template parameterâ.
Move such directives up to the nearest statement, interface operation, model property, operation parameter, union variant, or enum member.
For the above example, that would be:
Deprecations
TypeSpec > @typespec/rest
- @segmentSeparator
is deprecated. The @actionSeparator
decorator should be used instead.
Before
After:
TypeSpec
Deprecated uri
being replaced by url
Before:
Now:
Config
- Deprecated emitters
property in the tspconfig.yaml
The emitters
property of the configuration file has been deprecated and replaced by 2 new properties making it consistent with the CLI
Before:
After: