0

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)

2 Answers 2

1

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]);
Sign up to request clarification or add additional context in comments.

Comments

1

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! :}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.