Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Safer TypeScript - what are the differences to normal TypeScript

Tags:

typescript

Microsoft Research offers a new TypeScript compiler variant called Safer TypeScript:

http://research.microsoft.com/en-us/downloads/b250c887-2b79-4413-9d7a-5a5a0c38cc57/

I could not find any documentation on it, and I was unable to install it into my TypeScript 1.0 system, since it requires TypeScript 0.9.5.

What are the differences between TypeScript and Safer TypeScript?

like image 673
cheesus Avatar asked Jul 03 '14 06:07

cheesus


People also ask

What is TypeScript type safety?

TypeScript will produce a compile-time error if our code does not have that logical outcome. Plus, this code handles and clearly reports three separate error conditions that the any code does nothing about. Using unknown and type narrowing forced us to come face-to-face with and handle these error conditions.

Is TypeScript more secure?

TypeScript is not a perfect language by any means; it has flaws and can have security issues when used incorrectly. However, it is more secure than JavaScript, and when deciding between the two, TypeScript is what you should choose.

What are TypeScript types?

There are three main primitives in JavaScript and TypeScript. boolean - true or false values. number - whole numbers and floating point values. string - text values like "TypeScript Rocks"

What makes TypeScript different?

TypeScript is no different from JavaScript in its purpose but is used for developing large applications. TypeScript trans compiles (source to source compilation) to JavaScript. It follows an object-oriented programming language structure and supports features like classes, interfaces, namespaces, and inheritance.


1 Answers

The main difference is that TS* features runtime type checking as well as static type checking, whereas standard TypeScript is only a design and compile time feature.

This means plain JavaScript code that calls your TS* code will receive type errors when passing invalid types from untrusted code. The general idea is to prevent security problems which are often caused by attacks based on unchecked types.

More information can be found here:

http://research.microsoft.com/en-us/um/people/nswamy/papers/gradual-typing-embedded-securely-in-javascript-draft.pdf

I have also written a slightly less detailed summery of TS*.

like image 65
Fenton Avatar answered Sep 24 '22 00:09

Fenton