Test your website performance for free
Test your website performance

Getting Started with TypeScript

New in 1.25.0 [BETA]

Getting Started with TypeScript

The Scrivito SDK includes type definitions for the building blocks of Scrivito-related entities such as CMS objects and widgets.

If you are new to TypeScript, you might first want to check out typescriptlang.org or the many other resources on the web (e.g., What is TypeScript and why would I use it in place of JavaScript?) before diving straight in here.

To try out the Scrivito SDK’s TypeScript beta, just install the latest version of the SDK:

As an example, here’s how the “BlogOverviewWidget” class from the Scrivito Example Application would look like in TypeScript:

And here’s how the “BlogOverviewWidget” component from the Scrivito Example Application would look like in TypeScript:

As you can see, the BlogOverviewWidget type informs TypeScript that widget is a Scrivito.Widget, and hence, get can be called on it.

[New in 1.27.0]It also informs TypeScript about the type of the values get returns from the widget. For example, the result of widget.get("tags") is automatically assumed to be of the string[] type since tags is defined as stringlist. Analogously, widget.get("maxItems") is assumed to return a number | null.

Please be aware that definitions may be renamed or adjusted during the beta phase.