Releases: microsoft/typespec
Release list
typespec-stable@1.15.0
@typespec/compiler
Breaking Changes
-
#11552
usingstatements declared before a file-level(blockless) namespace are now resolved from the global namespace instead of the file namespace, matching C#.using TypeSpec.Http; // Now resolves the global `TypeSpec` namespace instead of `_Specs_.TypeSpec` namespace _Specs_.TypeSpec.Foo;
A
usingdeclared after the file namespace, or inside a namespace block, is unchanged and still resolves relative to that namespace. Code relying on a relative name in ausingwritten above the file namespace must now use the fully qualified name.namespace MyOrg.Service; using Models; // Still resolves to `MyOrg.Models`
Features
-
#11476 Add back empty project template to
tsp initoptions# Result of selecting "Empty project" in tsp init # main.tsp - minimal empty file to start from -
#11000 Add
setAutoDecoratorAPI to programmatically apply anautodecorator to a target, mirroring what the synthesizedauto decimplementation does when the decorator is written in source. This lets emitters and mutators mark synthetic types without reaching into the program state map directly.import { setAutoDecorator } from "@typespec/compiler"; setAutoDecorator(program, "MyLib.myFlag", target);
-
#11468 Add
Fix all: Xcode action for codefixes that can be applied to multiple instances in a file at once. When a codefix applies to more than one diagnostic of the same kind in a file, aFix all: <fix label>quick fix action is now suggested alongside the individual fix. -
#11209 Add support for short diagnostic and linter rule names. Diagnostic/rule codes can now be referenced by their scope-stripped short name (e.g.
http/no-fooinstead of@typespec/http/no-foo) or by a library-declaredalias, both in#suppressdirectives and in thelintersection oftspconfig.yaml. The full name is always accepted.model Post { #suppress "http/no-service-found" "standard library route" author: LegacyUser; }
Libraries can declare a custom alias:
export const $lib = createTypeSpecLibrary({ name: "@azure-tools/typespec-client-generator-core", alias: "tcgc", diagnostics: { /* ... */ }, } as const);
An
aliasmust be kebab-case (lowercase letters, digits, and hyphens). When two loaded libraries would resolve to the same short name, that short name is ambiguous: referencing it (in a#suppressdirective or thelinterconfig) reports a warning and the full name must be used. -
#11366 Language server folding ranges now report a
kind: comments fold ascommentand consecutiveimportstatements fold together as animportsregion. This enables editor commands such as "Fold All Block Comments" and "Fold All Imports" to work with TypeSpec files. -
#11318 Add
currentStageproperty anduseCachemethod toProgramfor stage-aware caching.currentStagetracks the compilation pipeline stage (parsing → checking → validating → linting → emitting), anduseCacheprovides a generic caching mechanism that libraries can use to avoid redundant computation during later stages. -
#11221 Add a
docsfield to linter rule and diagnostic definitions to provide extended reference documentation. The value can be an inline markdown string or aFileRefcreated withfileRef.fromPackageRoot("src/rules/my-rule.md"), which is read lazily by tooling so it stays safe to bundle for the browser.export const myRule = createRule({ name: "my-rule", severity: "warning", description: "Short description.", docs: fileRef.fromPackageRoot("src/rules/my-rule.md"), messages: { /* ... */ }, });
-
#11000
createTesternow mounts each discovered library'stspconfig.yamlinto the virtual file system, so experimental features a library opts into (e.g.auto-decorators) are honored when compiling against the tester.
Bug Fixes
- #11477 Fix decorators running with unresolved template parameters when a decorated template is used as a template parameter default of an operation (e.g.
op foo<Resource, Properties = Decorated<Resource>>(...), the ARMTagsUpdateModel<Resource>pattern). Operations now enter the template declaration scope before resolving template parameter defaults, so decorators on those defaults are no longer executed with the still-unresolved template parameter. This matches the existing behavior for models and interfaces. - #11423
tsp compile .now resolves the entrypoint fromexports["."]["typespec"]in package.json, taking precedence over the legacytspMainfield - #11485 Report better error message when specifying an emitter that is not installed with
--emitflag - #11426 IDE completion no longer adds unnecessary backticks when completing keyword identifiers in positions where they are allowed (model properties, object literal properties, member expressions).
- #11467
tsp inittemplatecompilerVersionfield now supports semver ranges (e.g.,^0.50.0). Plain versions like1.2.3continue to work as>=1.2.3for backward compatibility.
@typespec/http
Features
- #11318 Cache
getHttpOperationresults during linting and emitting stages usingprogram.useCache(). This eliminates redundant route resolution when multiple linter rules inspect the same operations, improving linter performance on large specs. - #11153 Add scope support to
OpenIdConnectAuth. The model now accepts an optionalScopestemplate parameter (OpenIdConnectAuth<ConnectUrl, Scopes>) and the OpenAPI3 emitter emits those scopes on each operation'sopenIdConnectsecurity requirement. The scheme object itself remains unchanged (scopes are discovered via theopenIdConnectUrl). ExistingOpenIdConnectAuth<Url>usages are unaffected.
@typespec/openapi
Features
-
#11309 Add
identifierfield to theLicensemodel in@typespec/openapi. This is an SPDX license expression for the API (e.g."MIT","Apache-2.0"). Theidentifierandurlfields are mutually exclusive. For OpenAPI 3.1+,identifieris emitted as-is; for OpenAPI 3.0, it is emitted as thex-oai-license-identifierextension. Importing an OpenAPI document also supports reading backidentifier(orx-oai-license-identifierfor 3.0 documents).@info(#{ license: #{ name: "MIT", identifier: "MIT" }, }) namespace MyService;
@typespec/openapi3
Features
-
#11309 Add
identifierfield to theLicensemodel in@typespec/openapi. This is an SPDX license expression for the API (e.g."MIT","Apache-2.0"). Theidentifierandurlfields are mutually exclusive. For OpenAPI 3.1+,identifieris emitted as-is; for OpenAPI 3.0, it is emitted as thex-oai-license-identifierextension. Importing an OpenAPI document also supports reading backidentifier(orx-oai-license-identifierfor 3.0 documents).@info(#{ license: #{ name: "MIT", identifier: "MIT" }, }) namespace MyService;
-
#11154 Extend the
enum-strategy: annotatedemitter option to unions of literals. When set toannotated, a union whose variants are literals is emitted as aoneOf/anyOfofconstsubschemas with per-varianttitle/descriptiontaken from@summaryand@doc, instead of collapsing to a single lossyenum. Supported for OpenAPI 3.1.0 and above; emitting with OpenAPI 3.0.0 falls back to the default form and reports a warning.For example, the following TypeSpec:
/** Set of known error types. */ union ErrorType { /** Common error for a bad request. */ @summary("CommonBadRequest") commonBadRequest: "https://example.com/errors/bad-request", /** The request body could not be parsed. */ @summary("InvalidBody") invalidBody: "https://example.com/errors/invalid-body", }
emits:
ErrorType: description: Set of known error types. anyOf: - const: https://example.com/errors/bad-request title: CommonBadRequest description: Common error for a bad request. - const: https://example.com/errors/invalid-body title: InvalidBody description: The request body could not be parsed.
Use
@oneOfon the union to emitoneOfinstead ofanyOf. -
#11153 Add scope support to
OpenIdConnectAuth. The model now accepts an optionalScopestemplate parameter (OpenIdConnectAuth<ConnectUrl, Scopes>) and the OpenAPI3 emitter emits those scopes on each operation'sopenIdConnectsecurity requirement. The scheme object itself remains unchanged (scopes are discovered via theopenIdConnectUrl). ExistingOpenIdConnectAuth<Url>usages are unaffected.
Bug Fixes
- #11427 Fix duplicate type name error when a model with a `@...
@typespec/xml@0.85.0
No changes, version bump only.
@typespec/versioning@0.85.0
No changes, version bump only.
@typespec/tspd@0.77.0
Features
- #11221
tspd docnow generates a documentation page per linter rule (reference/rules/<name>.md) and per diagnostic (reference/diagnostics/<code>.md), sourced from thedocsfield on the rule and diagnostic definitions. Adocumentation-missingwarning is reported for any linter rule or diagnostic that does not provide documentation. - #11000
tspd gen-extern-signaturenow also generates a typed setter (e.g.setMyFlag,setMyLabel) for eachautodecorator, alongside the existingis*/get*readers. - #11316 Add a
--rules-diroption (andrulesDirAPI option) totspd docto control where per-rule reference pages are written. Defaults torules(relative to--output-dir); can be set to a path escaping the output dir (e.g.../rules) to keep rule pages outside the generated reference folder.
@typespec/streams@0.85.0
No changes, version bump only.
@typespec/sse@0.85.0
No changes, version bump only.
@typespec/rest@0.85.0
No changes, version bump only.
@typespec/protobuf@0.85.0
No changes, version bump only.
@typespec/playground@0.17.0
Features
- #11468 Add support for the
Fix all: Xcode action in the playground, allowing a codefix that appears multiple times in a file to be applied to all instances at once.
Bug Fixes
- #11508 Add support for deferring the loading of emitter libraries until they are selected. Configure with the new
deferredEmittersoption to avoid downloading and evaluating large emitters on startup.
@typespec/library-linter@0.85.0
Features
-
#11543 Add
missing-documentationandextraneous-documentationrulesmissing-documentationreports public declarations and members of a library that have no doc
comment or@doc, so gaps in the generated reference documentation are caught at build time.extraneous-documentationreports doc comments that document something that doesn't exist, such as
a@paramnaming a parameter the operation doesn't have, a@templatecopied from an enclosing
interface, or an unescaped code reference the parser mistook for a tag:/** * Creates or updates an instance of the resource. * @template Resource The resource model. // `create` is not templated: the interface is */ create(resource: Resource): Resource;
Declarations in a
Privatenamespace and declarations markedinternalare excluded.