Reputation: 4233
I'm used to dynamic languages, but TypeScripts structural typing sounds like an almost dynamic addition to JavaScript.
Now I read, TypeScript would eliminate many unit-tests a JavaScript program needs.
What kind of unit-tests are essential for TypeScript 2.0?
What errors can't the type checker get?
(I'm asking for TS2, because I guess the new additions of flow-analysis and non-nullable-types eliminate their own kind of tests)
Upvotes: 0
Views: 46
Reputation: 3109
What kind of unit-tests are essential for TypeScript 2.0?
Ask yourself,
What kind of unit-tests are essential for Javascript?
There are an infinite number of errors that Typescript can't catch. TypeScript will eliminate a lot of errors that dynamic languages can't, so that leaves (infinity - some = infinity) errors left for you to check. Good Luck! :}
Upvotes: 1
Reputation: 276393
What errors can't the type checker get
The ones that aren't expressed in the type system. e.g. the length of a character isn't expressed:
let x: string;
x = theValueThatWasReceivedFromServer;
// read the 10th character
// As far as ts is concerned it is okay.
// It might be undefined based on the value that came from the server
console.log(x[10]);
Upvotes: 1