0.67
Notable changes
Section titled âNotable changesâtsp install now download and use the configured package manager
Section titled âtsp install now download and use the configured package managerâIn order to detach typespec from any specific package manager, tsp install now uses the package manager configured in packageManager or devEngines.packageManager field of package.json. If the field is not present, it defaults to npm latest version but will log a warning.
{ // Use npm 11.2.0 with sha512 checksum verification "packageManager": "npm@11.2.0+sha512.3dc9c50ba813a3d54393155a435fe66404b72685ab0e3008f9ae9ed8d81f6104860f07ed2656dd5748c1322d95f3140fa9b19c59a6bba7750fd12285f81866da", // Use npm 11.2.0 but skip integrity check "packageManager": "npm@11.2.0"}The field can be automatically set by running tsp install --save-package-manager
Breaking Changes
Section titled âBreaking ChangesâAll packages
Section titled âAll packagesâ- #5977 Minimum node version is now 20
@typespec/compiler
Section titled â@typespec/compilerâ-
#6231 Remove deprecated items:
-
@deprecateddecorator, use#deprecateddirective instead@deprecated("Message")#deprecated "Message" -
@serviceversionssupport. Either migrate to@OpenAPI.infoor the versioning library@service({version: "1.0"})@service@OpenAPI.info(#{version: "1.0"}) -
Removed
@knownValues. Use a union with a string variant insteadenum MyKnownValues {a, b}@knownValues(MyKnownValues)scalar Custom extends string;union Custom {"a", "b", string}; -
Removed
@projectedNameMigrate to@encodedNameinstead.@projectedName("json", "nbf")@encodedName("application/json", "nbf")notBefore: int32; -
CLI configuration value
output-path, useoutput-dirinstead. -
Support for
cadlMaininpackage.json. Migrate toexports["."].tspinstead."cadlMain": "lib/main.tsp","exports": {".": {"tsp": "lib/main.tsp"}} -
Compiling
.cadlfiles, use.tspinstead. -
decoratorArgMarshallingflag in$flagswas removed and support for thelegacydecorator arg marshalling. -
Using
@formaton bytes.@formatcan only be used on string where it defines a known pattern for the string. -
Javascript functions and typescript types:
stringTemplateToStringCadlLanguageConfigurationCadlPrettierPluginNodePackage->PackageJsonCadlValue->TypeSpecValuecreateCadlLibrary->createTypeSpecLibrarysetCadlNamespace->setTypeSpecNamespaceCadlLibrary->TypeSpecLibrarySyntaxKind.CadlScript->SyntaxKind.TypeSpecScriptisCadlValueTypeOf->isTypeSpecValueTypeOfcadlTypeToJson->typespecTypeToJsoncheckFormatCadl->checkFormatTypeSpeccadlVersion->typespecVersionCadlManifest->TypeSpecManifestvalidateDecoratorTargetIntrinsic-> Useextern decto define the signature of decorators insteadvalidateDecoratorParamType-> Useextern decto define the signature of decorators insteadcreateDecoratorDefinition-> Useextern decto define the signature of decorators insteadCompilerOptions#emitters-> Useemitandoptionsfield instead.emitters: { "my-emitter": options },emit: ["my-emitter"],options: { "my-emitter": options },Type#templateArguments-> UsetemplateMapperinstead.ModelProperty#default-> UsedefaultValueinstead.Union#options-> Usevariantsinstead.linterincreateTypeSpecLibrary-> Useexport const $linter = defineLinter({ ... })instead.- Accessor for removed
@knownValuesdecoratorgetKnownValues
- Accessor for removed
@projectedNamedecoratorgetProjectedNamesgetProjectedNamehasProjectedName
-
-
#6323 Move AST related APIS to
@typespec/compiler/astpackage. This is to mark a clear separation for the AST types and APIs which are considered for advanced usage and might change at any time.- All
*Nodetypes exprIsBareIdentifiergetFirstAncestorgetIdentifierContextgetNodeAtPositiongetNodeAtPositionDetailhasParseErrorisImportStatementparseparseStandaloneTypeReferencepositionInRangevisitChildren
- All
-
#6323 Stop exposing APIs that were not meant for external users. Please file issue if you had legitmate use of some of those APIs.
-
Checker: The check itself should be used very carefully and its wouldnât be covered under the compatibility guarantees. There is some apis that were explicitly marked as internal while other remained until we provide a better way to do the same thing:getGlobalNamespaceType();->program.getGlobalNamespaceType();resolveTypeReference();->program.resolveTypeReference();checkProgram();This isnât meant to be used by external users.getLiteralType()This isnât meant to be used by external users.resolveRelatedSymbols()This isnât meant to be used by external users.resolveCompletions()This isnât meant to be used by external users.
-
Program: Exposed functions on the program are safe to use but a few have been updated to be internal:mainFile-> UseprojectRootinstead.literalTypesThis isnât meant to be used by external users.checker: This is still exposed but to be used carefully, see above.loadTypeSpecScript: This isnât meant to be used by external users.onValidate: This isnât meant to be used by external users.reportDuplicateSymbols: This isnât meant to be used by external users.
-
logVerboseTestOutputInternal test util, not meant for external users -
validateDecoratorTarget-> migrate toextern decdeclaration -
validateDecoratorParamCount: Same as above -
altDirectorySeparator: Internal path utils -
directorySeparator: Internal path utils -
isIntrinsicType: Internal check -
getFullyQualifiedSymbolNameSymbols are an internal aspect of the compiler -
Scanner related APIs:
createScannerisCommentisKeywordisModifierisPunctuationisStatementKeywordisTriviaskipContinuousIdentifierskipTriviaskipTriviaBackwardskipWhiteSpaceTokenTokenFlagstypeDocToken,typeScanner,typeStringTemplateToken,
-
Types
SymSymbols are an internal aspect of the compilerSymbolLinksSymbols are an internal aspect of the compilerSymbolTableSymbols are an internal aspect of the compilerSymbolFlagsSymbols are an internal aspect of the compilerMutableSymbolTableSymbols are an internal aspect of the compilerResolutionResultInternal type used in non exposed resolverNodeLinksInternal type used in non exposed resolverResolutionResultFlagsInternal type used in non exposed resolverMetaMemberKeyUnused typeMetaMembersTableUnused typeDirentUnused type
-
-
#6410 Remove a legacy behavior of resolving package names which wasnât inline with node ESM module resolution.
For example if you were running tsp compile within your node_modules folder(on a test package) and referencing your emitter by name you might need to change this
Terminal window tsp compile . --emit my-emittertsp compile . ../../ # path to your emitter root instead -
#6286 Removed deprecated use of
@discriminatoron union. Migrate to@discriminated@discriminator("type")@discriminated(#{envelope: "none", discriminatorPropertyName: "type"})union Pet; -
#6327 Remove projection. Projection was an experiemental syntax that was too flawed to be included in 1.0 in that current state.
-
#6388 Remove deprecated type to value conversion. Since the introductions of object values(
#{}) and array values(#[]) using model expressions or tuple where values were expected has been deprecated. It is now an error with a codefix.@service({title: "My service"})@service(#{title: "My service"}) -
#6416 Adding new keywords for future use:
statemachinemacropackagemetadataenvargdeclarearraystructrecordmodulemodpubsubtypereftraitthisselfsuperkeyofwithimplementsimplsatisfiesflagautopartialprivatepublicprotectedinternalsealedlocalasync
-
#6258 Removed deprecated legacy visibility APIs and converted all warnings for using string-based visibility modifiers to errors.
The removed APIs include:
getVisibility: usegetVisibilityForClassinstead.getParameterVisibility: usegetParameterVisibilityFilterinstead.getReturnTypeVisibility: usegetReturnTypeVisibilityFilterinstead.
Furthermore, the legacy signature of
isVisiblethat accepts an array of strings has been removed. Please use the new signature that acceptsEnumMemberinstead.The changed decorators include:
@visibility@parameterVisibility@returnTypeVisibility@withVisibility@withDefaultKeyVisibility
The
TypeSpec.DefaultKeyVisibilitytemplate also no longer accepts a string as a visibility modifier argument.Attempting to pass a string to any of the above decorators or templates will now result in a type-checking error. Please use the
Lifecyclevisibility modifiers instead.If you develop a third-party library and you use any custom visibility modifiers, you will need to instead define a visibility class enum. See: Visibility | TypeSpec.
Migration steps:
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 has been made an error. Previously, some specifications used it to disable effective PATCH optionality, but that behavior was an unintended side effect. For example:@parameterVisibility@patchop example(@bodyRoot resource: Resource): Resource;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;
@typespec/http
Section titled â@typespec/httpâ-
#6387 Removing deprecated items
-
isContentTypeHeader -
setLegacyStatusCodeState
Moved to internal
-
setStatusCode -
#6305 Remove deprecated items:
-
formatoption from@headerand@querydecorators. Useexplodeoption instead.@header(#{ format: "multi"})@query(#{ format: "multi"})@header(#{ explode: true })@query(#{ explode: true }) -
sharedoption from@routedecorator. Please use@sharedRouteinstead.@route("/doStuff", { shared: true })@sharedRoute@route("/doStuff") -
Javascript functions and typescript types:
HeaderOptions.formatHeaderFieldOptions.formatQueryOptions.formatQueryParameterOptions.formatMetadataInfo.isEmptiedincludeInterfaceRoutesInNamespacegetAllRoutes->getAllHttpServicesOperationDetails->HttpOperationServiceAuthentication->AuthenticationHttpOperationParameters.bodyType->body.typeHttpOperationParameters.bodyParameter->body.parameterStatusCode->HttpStatusCodesEntry
-
#6433 Stop exposing APIs that were not meant for external users. Please file issue if you had legitmate use of some of those APIs.
@includeInapplicableMetadataInPayloaddecorator was moved toPrivatenamespace and stop exposing the accessor.- Functions used in
getHttpOperationto resolve the finalized view of the http operation but shouldnât be used directly.resolvePathAndParameters
validateRouteUniqueinternal api used in http library validation- Moved custom route producer related APIs to experimental with
unsafe_prefix. Those APIs are not ready for public use and will change in future.DefaultRouteProducer->unsafe_DefaultRouteProducergetRouteProducer->unsafe_getRouteProducersetRouteProducer->unsafe_setRouteProducersetRouteOptionsForNamespace->unsafe_setRouteOptionsForNamespaceRouteProducer->unsafe_RouteProducerRouteProducerResult->unsafe_RouteProducerResultRouteResolutionOptions->unsafe_RouteResolutionOptionsRouteOptions->unsafe_RouteOptions
-
#6357 Changed the default content-type resolution behavior as follows:
-
As before, if the content-type header is explicitly specified (
@header contentType: valueof string), the explicit content type is used (this behavior has not changed). -
If the type of an HTTP payload body has a Media Type hint (
@mediaTypeHint), that media type is preferred as the default content-type for the request. -
The default content-type for
TypeSpec.byteshas been changed toapplication/octet-streamto avoid serializing the data to base64-encoded JSON. -
The default content-type for all other scalar types has been changed to
text/plain(previously, it wasapplication/json). -
For multipart payloads, the default content-type of the payload has been changed to
multipart/form-dataif the@multipartBodyparameter has a Model type andmultipart/mixedif the multipart payload has a tuple type.- The content-type of individual parts in the multipart request has been changed to be the same as for HTTP payload bodies and follows the logic described above.
@typespec/versioning
Section titled â@typespec/versioningâ-
#6327 Remove deprecated versioning projection, switch to the mutator approach
// Step 1: Update to retrieve the mutation instead of projectionsconst versions = buildVersionProjections(program, service.type);const versions = getVersioningMutators(program, service.type);// Step 2: call mutator instead of projection apiconst projectedProgram = projectProgram(originalProgram, versionRecord.projections);const subgraph = unsafe_mutateSubgraphWithNamespace(program, [mutator], service.type);subgraph.type // this is the mutated service namespace
Deprecations
Section titled âDeprecationsâ@typespec/compiler
Section titled â@typespec/compilerâ-
#6310 Deprecate
@typespec/compiler/emitter-frameworkexport in favor of a new package@typespec/asset-emitterpackage.json "dependencies": {"@typespec/asset-emitter": "0.67.0"}import { TypeEmitter, ... } from "@typespec/compiler/emitter-framework";import { TypeEmitter, ... } from "@typespec/asset-emitter"; -
#6306 Remove the use of deprecated getDiscriminatedUnion
@typespec/http
Section titled â@typespec/httpâ-
#6464 Deprecate implicit multipart body
op upload(@header contentType: "multipart/form-data",@body body: {@multipartBody body: {name: string;name: HttpPart<string>;avatar: bytes;avatar: HttpPart<bytes>;}): void;
@typespec/openapi3
Section titled â@typespec/openapi3â- #6305 Related changes based on
httplibrary deprecation removal.
Features
Section titled âFeaturesâ@typespec/compiler
Section titled â@typespec/compilerâ- #6411 Introduce a new
dryRuncompiler option(--dry-runin the cli) that emitters can opt-in to support by settingcapabilities.dryRunin their$lib. - #6411 Update
noEmitcompiler option (--no-emitcli flag) to prevent emitter to run. A newdryRunoption has been added to achieve a safer similar result where emitters run but do not write output. - #6220
tsp installnow downloads and uses the configured package manager indevEngines.packageManagerorpackageManagerfield ofpackage.json - #6357 Add support for
@mediaTypeHintto apply a hint for default Media/MIME type (Content-Type in HTTP) to a TypeSpec type.
@typespec/http
Section titled â@typespec/httpâ- #6345 Update
BasicAuthandBearerAuthtypes scheme to use standard name for schemeBasic,Bearer - #6327 Remove reference to delete projection feature
@typespec/openapi3
Section titled â@typespec/openapi3â- #6268
@typespec/versioningis now an optional dependency. - #6286 Remove support for
@discriminatoron union - #6327 Remove reference to delete projection feature
@typespec/protobuf
Section titled â@typespec/protobufâ- #6327 Remove reference to delete projection feature
@typespec/html-program-viewer
Section titled â@typespec/html-program-viewerâ- #6327 Remove reference to delete projection feature
typespec-vscode
Section titled âtypespec-vscodeâ- #6178 Update references to JS emitter
- #5972 Select multiple emitters to generate multiple codes at one time
- #6295 Improve the âCreate TypeSpec Projectâ user experience
- #6015 add openapi3 preview
- #6123 Support telemetry
Bug Fixes
Section titled âBug Fixesâ@typespec/compiler
Section titled â@typespec/compilerâ- #6335 Improvements to the CLI output
- #6309 Fixed an issue where the
--emit-filesflag on emitters with nested folders was not generating the correct paths to the files. - #6292 Fix
tsp initnot respecting default selected emitters
@typespec/rest
Section titled â@typespec/restâ- #6326 Updates
@autoRoutebehavior to apply same HttpOperationParameter filtering to HttpProperty
@typespec/openapi3
Section titled â@typespec/openapi3â- #6289 Fix
utcDateTimeandoffsetDateTimenot using formathttp-datein header by default as the default http encoding defines - #6411 Add support for new
dryRunemitter option - #6473 Adds support for
@encodeto specify array encodings for@queryparameters
@typespec/protobuf
Section titled â@typespec/protobufâ- #6411 Add support for new
dryRunemitter option
@typespec/json-schema
Section titled â@typespec/json-schemaâ- #6411 Add support for new
dryRunemitter option