We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top

TypeScript Meets API Design in Microsoft’s Game-Changing TypeSpec

submited by
Style Pass
2024-05-13 19:00:02

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

Microsoft recently introduced TypeSpec, a new API definition language and platform designed to meet the evolving needs of API developers, architects, and managers in an increasingly complex environment.

As the name implies, TypeSpec is related to TypeScript, the Microsoft-developed superset of JavaScript. Indeed, TypeSpec was inspired by two languages designed by Microsoft language guru, Anders Hejlsberg — TypeScript and C#. Like TypeScript, TypeSpec is open source.

“TypeScript inspired most of our syntax and type system semantics. TypeScript is really great at describing JSON data shapes, so we followed their lead there,” Brian Terlson, a principal architect at Microsoft and primary TypeSpec architect, told The New Stack. “From C#, we inherited the notion of namespaces and how they merge across files, which was a natural fit for an API description language. Overall, we try to leverage existing and well-understood patterns because we want TypeSpec to be familiar and easy to learn for as many developers as possible.”

TypeSpec can describe APIs using any protocol or serialization format with concise, familiar syntax and editor tooling support via Visual Studio and VS Code. It is described as a “minimal language” that helps developers describe API shapes in a familiar way.

Leave a Comment