Repository navigation
Releases
typespec-stable@1.18.0
@typespec/compiler
Deprecations
-
#11980
getDiscriminatedUnionFromInheritance(type, discriminator)is deprecated. Pass the program as the first argument so enum member discriminator values use their@encodedName.const [union, diagnostics] = getDiscriminatedUnionFromInheritance(program, type, discriminator);
Features
-
#12095 Inspect inline suppressions and local linter disables without compiling a project. Inline results include declaration context and source locations; config results include rule-key locations and diagnostics. For compiled programs, inspect whether each project suppression matched a diagnostic using
getSuppressions.import { collectLinterDisables } from "@typespec/compiler"; import { collectSuppressions, getSuppressions, parse } from "@typespec/compiler/ast"; const script = parse(source); const suppressions = collectSuppressions(script); const [disables, diagnostics] = collectLinterDisables(configText); const observedSuppressions = getSuppressions(program); // Includes a `used` flag.
Usage is a snapshot of diagnostics matched so far in that compilation, including rejected attempts to suppress errors. An unmatched suppression may be needed under other settings: its rule could be disabled, its diagnostic source unavailable, its emitter skipped, or compilation could stop before the relevant stage runs.
-
#12195 Override linter configuration for a single compilation without editing
tspconfig.yaml. Select rulesets with--linter-ruleset, enable, disable, or configure individual rules with--linter-rule, and skip linting with--no-linter.tsp compile . --linter-ruleset @typespec/http/all tsp compile . --linter-rule @typespec/compiler/unused-using=true tsp compile . --no-linter
-
#12166 Expose
skipTriviathrough@typespec/compiler/astso codefixes can reuse the compiler whitespace and comment handling.import { skipTrivia } from "@typespec/compiler/ast"; const cursor = skipTrivia(sourceText, property.end, property.parent?.end);
-
#12461 Add
typeref(Type)for referencing types from metadata values. Enable thetyperefcompiler feature in the calling project or library'stspconfig.yaml. Its result has typeTypeRef<T>, whereTis the referenced type. UseTypeRefto accept any type reference, orTypeRef<T>to constrain its target. JavaScript implementations and generated signatures useTypeRefValuefrom@typespec/compiler, whosetargetis the referenced compiler type. Type references are compilation metadata and cannot be represented as JSON values.model Item { id: string; } model Registration { name: string; type: TypeRef; } const entry: Registration = #{ name: "item", type: typeref(Item) };
-
#12399 [API] Widen
isTemplateDeclarationandisTemplateDeclarationOrInstanceto accept anyType.
Bug Fixes
-
#12314 Suppress deprecated type warnings in deprecated operations, including parameter and response types nested in inline models and template arguments.
-
#12225 Preserve source model and property documentation in generated extern signatures.
-
#11980
@encodedNameon an enum member now sets the value the member is serialized as, including when it has an explicit value. Emitters can resolve it withresolveEncodedEnumMemberValue. A spec that relied on the encoded name being ignored can now report errors, such as an encoded name equal to another member's value, or a@discriminatedunion variant named after the member instead of its encoded name.enum ConversationStatus { // Keeps 0 for protobuf, serialized as "unknown" in JSON @encodedName("application/json", "unknown") CONVERSATION_STATUS_UNSPECIFIED: 0, }
-
#12323 Fix the underline in the diagnostic source preview starting one character to the right of the target since the upgrade to
@babel/code-frame8. -
#12202 Highlight type-reference names without their template arguments when reporting diagnostics.
-
#12358 Fix decorators being skipped when concrete types are first referenced from template declarations, including references through model properties, union variants, and enum members.
-
#12204 Recommend npm run build instead of tsp compile . after initializing a TypeSpec library or emitter.
-
#12180 Fix
enumMemberandexitEnumMembersemantic navigation callbacks so linter rules can validate enum members. Scoped navigation uses the parent enum's namespace to avoid visiting members outside the requested scope. -
#12203 Explain that createTester requires a library root directory when its package.json cannot be found.
-
#12461 Correct reflection type constraint comparisons in function signatures, template parameters, and type references so namespace and other non-model constraints are not accepted as model constraints.
@typespec/http
Bug Fixes
- #12225 Preserve source model and property documentation in generated extern signatures.
- #12087 Improve HTTP payload resolution performance for models with many properties by avoiding repeated metadata scans.
@typespec/openapi
Bug Fixes
- #12225 Preserve source model and property documentation in generated extern signatures.
@typespec/openapi3
Features
-
#12461 Add
typeref(Type)for referencing types from metadata values. Enable thetyperefcompiler feature in the calling project or library'stspconfig.yaml. Its result has typeTypeRef<T>, whereTis the referenced type. UseTypeRefto accept any type reference, orTypeRef<T>to constrain its target. JavaScript implementations and generated signatures useTypeRefValuefrom@typespec/compiler, whosetargetis the referenced compiler type. Type references are compilation metadata and cannot be represented as JSON values.model Item { id: string; } model Registration { name: string; type: TypeRef; } const entry: Registration = #{ name: "item", type: typeref(Item) };
Bug Fixes
- #11980 Enum members use their
application/json@encodedNameas their value, including in a server variable; an encoded integer member is emitted as a string. - #12300 Reduce the visibility context of array declarations so that named array models are not incorrectly emitted with an
Itemsuffix. - #12368 Deduplicate identical summaries and descriptions across
@sharedRouteoperations. - #12092 [converter] Escape quotes in the
@servicetitle generated from the OpenAPIinfo.title. - #12021 Fix
@terminalEventon a variant with a payload emitting an unconstrainedoneOfbranch in OpenAPI 3.2 SSE output - #11990 Preserve distinct discriminated union envelopes when variants share the same payload type.
- #12165 Emit
minItemsandmaxItemsfor tuple types so generated schemas enforce the tuple's exact length.
@typespec/json-schema
Features
-
#12461 Add
typeref(Type)for referencing types from metadata values. Enable thetyperefcompiler feature in the calling project or library'stspconfig.yaml. Its result has typeTypeRef<T>, whereTis the referenced type. UseTypeRefto accept any type reference, orTypeRef<T>to constrain its target. JavaScript implementations and generated signatures useTypeRefValuefrom@typespec/compiler, whosetargetis the referenced compiler type. Type references are compilation metadata and cannot be represented as JSON values.model Item { id: string; } model Registration { name: string; type: TypeRef; } const entry: Registration = #{ name: "item", type: typeref(Item) };
Bug Fixes
- #11980 Enum members use their
application/json@encodedNameas their value, including members with an explicit value. An encoded integer member is emitted as a string. - #12330 Report a diagnostic instead of crashing when
@prefixItemsreceives an array type rather than a tuple.
typespec-vscode
No changes, version bump only.
@typespec/prettier-plugin-typespec
No changes, version bump only.
@typespec/xml@0.88.0
No changes, version bump only.
@typespec/versioning@0.88.0
Bug Fixes
- #11968 Preserve transformed property optionality in version snapshots and skip incompatible optionality diagnostics when the property differs from its original declaration, without special-casing transformation helpers.
@typespec/tspd@0.78.0
Features
-
#12461 Add
typeref(Type)for referencing types from metadata values. Enable thetyperefcompiler feature in the calling project or library'stspconfig.yaml. Its result has typeTypeRef<T>, whereTis the referenced type. UseTypeRefto accept any type reference, orTypeRef<T>to constrain its target. JavaScript implementations and generated signatures useTypeRefValuefrom@typespec/compiler, whosetargetis the referenced compiler type. Type references are compilation metadata and cannot be represented as JSON values.model Item { id: string; } model Registration { name: string; type: TypeRef; } const entry: Registration = #{ name: "item", type: typeref(Item) };
Bug Fixes
- #12225 Preserve source model and property documentation in generated extern signatures.
- #12435 Mark generated Typekit reference pages as JavaScript APIs so scoped website search includes them in
api:searches instead of default documentation searches. - #12169 Render line breaks in wrapped typekit documentation as whitespace instead of leaking TSDoc node names.
@typespec/streams@0.88.0
No changes, version bump only.
@typespec/sse@0.88.0
No changes, version bump only.
@typespec/rest@0.88.0
No changes, version bump only.
@typespec/protobuf@0.88.0
Features
-
#12131 Add
LongRunningOperation<Response, Metadata>for long-running operations (AIP-151), andWellKnown.Operation. An operation that returnsLongRunningOperationreturns agoogle.longrunning.Operation, and the emitter writes its response and metadata types in the method'sgoogle.longrunning.operation_infooption.importBooks(...ImportBooksRequest): LongRunningOperation<ImportBooksResponse, ImportBooksMetadata>;
rpc ImportBooks(ImportBooksRequest) returns (google.longrunning.Operation) { option (google.longrunning.operation_info) = { response_type: "ImportBooksResponse" metadata_type: "ImportBooksMetadata" }; }
Bug Fixes
- #12191 An object value, such as an
@opExampleorconstvalue, can now fill aMap<Key, Value>:Mapis aRecordof its values. The emittedmapis unchanged.
@typespec/playground@0.19.0
Breaking Changes
-
#12200 Move
registerMonacoDefaultWorkersForVitefrom@typespec/playgroundto@typespec/playground/vite/workers. Update the import path; the registration call is unchanged.Custom Vite configurations must exclude
@typespec/playground/vite/workersfromoptimizeDeps.definePlaygroundViteConfigconfigures this automatically.
Bug Fixes
@typespec/library-linter@0.88.0
No changes, version bump only.