microsoft/typespec typespec-stable@1.16.0
microsoft/typespec
Captured source
source ↗typespec-stable@1.16.0
Repository: microsoft/typespec
Tag: typespec-stable@1.16.0
Published: 2026-09-09T19:44:45Z
Prerelease: no
Release notes:
@typespec/compiler
Features
- #11777 Add
sanitizePathSegmenthelper to make a value coming from a TypeSpec spec safe to use as a single path segment. Path separators, drive letter separators and values only made of.are replaced with_.
sanitizePathSegment("2021-10-01-preview"); // "2021-10-01-preview"
sanitizePathSegment("../../etc/passwd"); // ".._.._etc_passwd"- #11851 Add support for defining a linter ruleset in a standalone yaml file and referencing it with the
file:prefix inlinter.extends. This lets a repository share and version a set of linter rules without depending on a library release.
# tspconfig.yaml linter: extends: - "file:../common-rules.yaml"
# common-rules.yaml extends: - "@typespec/best-practices/recommended" enable: "@typespec/best-practices/new-rule": true disable: "@typespec/best-practices/foo": "This rule is too strict for this repository"
- #11489 Add a new experimental
$provideTypeInfolibrary provider andprogram.getTypeInfo(type)API allowing libraries to contribute extra, domain-specific information about types. Unlike the$onValidatelifecycle hook, a provider never runs during compilation and must not mutate the type graph — it is invoked lazily and on demand (e.g. by the language server for hover documentation, or by tooling querying the type).
Providers are gated by the type-info-provider compiler feature, scoped to the package that declares it: a library opts in via its own tspconfig.yaml and consumers do not need to enable anything.
// A library exports a provider (use `defineTypeInfoProvider` for typing):
export const $provideTypeInfo = defineTypeInfoProvider(({ program, target }) => {
if (target.kind !== "Operation") return undefined;
return { content: "extra info about this operation" };
});
// Tooling / language server queries it (merges every library's contribution):
const info = program.getTypeInfo(type);- #11771 Add experimental support for an
extendsclause on union statements to constrain every variant to a common data type.
Enable the union-extends compiler feature in tspconfig.yaml to use the clause.
model PetBase {
name: string;
}
model Cat extends PetBase {
toy: string;
}
model Dog extends PetBase {
food: string;
}
union Pet extends PetBase {
cat: Cat,
dog: Dog,
}The base type is exposed on the type graph as Union.baseType, giving emitters an easy way to know that all the variants of a union share a common base type. A diagnostic is reported on any variant that isn't assignable to the base type.
extends on a union is purely a constraint: it doesn't imply any subtyping relationship, it doesn't make the union extensible and it has no interaction with @discriminator.
Bug Fixes
- #11731 Fix
durationexample values being serialized verbatim as an ISO 8601 string instead of a numeric value when encoded with@encode("milliseconds", ...) - #11744 Fix object values passed to decorators dropping members with special names like
__proto__. All members are now defined as plain own properties. - #11779 Fix a stack overflow when checking assignability of mutually recursive types
Checking whether a type was assignable to another one could recurse forever and crash the compiler with RangeError: Maximum call stack size exceeded. Two cases were affected:
- mutually recursive models, such as
model A { b: B }/model B { a: A } - any union reaching itself, such as
union Foo { self: Foo }
The relation cache is now shared for the whole check instead of being recreated at every level, and unions seed it before walking their variants, so a cycle coming back to the same pair of types resolves instead of recursing.
- #11838 [formatter] Split the template parameter list instead of splitting a parameter constraint or default when the declaration is too long
// Before op deleteJobPreview is FoundryDataPlanePreviewOperation; // After op deleteJobPreview is FoundryDataPlanePreviewOperation;
- #11776 Allow
tsp installto download package managers from npm-compatible registry mirrors by resolving versions from package metadata instead of version-specific manifest endpoints. - #11551 Improve the name reported for an operation's parameters model expression. Diagnostics now refer to
MyService.test::parameters.paraminstead ofMyService.{ param: MyService.Foo }.param.
@typespec/http
Features
- #11489 Add a
$provideTypeInfoprovider that surfaces the resolved HTTP route (verb and URI template) and response status codes of an operation. This is shown when hovering an operation in the IDE and can be queried programmatically viaprogram.getTypeInfo(operation).
const info = program.getTypeInfo(operation);
// { content: "`HTTP Route`: `GET /pets/{id}`\n\n`Responses`: `204`" }Bug Fixes
- #11785 Respect docs on union variants used as HTTP responses
@typespec/openapi
Bug Fixes
- #11744 Fix
@extensiondropping object members with special names like__proto__. All members are now kept as plain own properties.
@typespec/openapi3
Bug Fixes
- #11777 Sanitize the spec provided values interpolated in
output-file({version},{service-name}and{service-name-if-multiple}) so a version or namespace name containing path separators cannot write the OpenAPI document outside of the emitter output dir.
@typespec/json-schema
Bug Fixes
- #11777 Sanitize declaration names used as file names so a declaration named with a backticked identifier containing path...
Excerpt shown — open the source for the full document.