Yes, we support TypeScript in our Browser SDK. This post explains the advantages of using TypeScript for JavaScript development.
What is TypeScript?
TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. TypeScript envelopes normal JavaScript and adds additional functions. It eliminates whole classes of bugs and improves the development process.
Why TypeScript?
JavaScript is fast, simple, and easy to learn. It's a dynamically typed language, meaning that variables’ types are assigned at run time. TypeScript keeps this from becoming a problem through its type checking feature.
What are the benefits of TypeScript?
You can credit Typescript's rapid growth to several prominent benefits:
1. Static typing helps developers write more robust code by detecting bugs while writing scripts, resulting in better, cleaner code compared to JavaScript.
Example: Here’s a code snippet where we’ve defined a string value for a variable, when actually it should have been an integer. You can see how the SDK itself throws a type error to change the value to an integer during compile time.
2. Type annotations: One of the main objectives of TypeScript is to identify static constructs that are possible errors. Its ability to do this allows developers to make safe assumptions about state while in execution.
In this example, you can see how Type annotations prevent operations from executing if the object type is unexpected. This helps developers avoid these kinds of bugs at compile time.
3. Better for collaboration: When teams of developers build large-scale applications you have an increased chance of coding errors. The type safety technique in TypeScript helps developers find code errors while writing the code and not during compilation, which results in a more efficient debugging process and better collaboration opportunity.
4. Enhanced productivity: TypeScript builds in features like auto compilation, ECMAScript 6 code support, and dynamic typing that help the compiler create highly optimized code and boost developers' productivity.
You can see the capabilities of our Browser SDK by checking out some sample applications and start using it yourself with help from our Browser SDK documentation.