In this article, we are going learn about What is Typescript? What does it do? Installation process. After reading this article you will have a lit...
For further actions, you may consider blocking this person and/or reporting abuse
That's actually the point of typescript. It adds a type system but since its transpiled into javascript, they can implement latest ES6 syntax without breaking browser compatability.
Some of the features typescript had before javascript are classes, logical assignment operators, decorators (still not implemented in js afaik), optional chaining, etc.
You are correct. TypeScript add static typing to your JavaScript code, while still maintaining compatibility with older versions of browsers. That's why you can use latest feature because eventually it will be transpiled to JavaScript. But I think mostly people use it because it can catch type errors at compile-time, rather than runtime.
Sure, but I was just pointing out your statement was objectively incorrect. Overall great post!
Thanks mate, I have changed the statement. :)
Type safety is not really the reason for swtiching to TypeScript. If that was the only one, you'd be better off just using JSDoc and a good IDE.
I agree with you that there are several reasons to use Typescript and Type safety is one of them.
It took a while for me to understand, that Typescript is not for runtime, it is for devtime 😇
Yes exactly, it lets you catch errors before you go to production.
TypeScript do not have types, it has type annotatations which is the worst of both worlds. No real type safety and slow development speed. if you want types, use a statically typed language, like rust or C++ and compile it to webassembly. If you want development speed and a flexibility, use JS.
I partially agree with your statement. Yes, TypeScript does have types and type annotations, but it can provide real type safety. What TypeScript does is that it add types & type annotations functionality to JavaScript and It can also compile the code to JavaScript. In fact, many developers use TypeScript specifically for the type safety.
TypeScript cannot provide typesafety. Please do some low level programming before you say something so misleading like TypeScript has type safety, because it is simply incorrect - if you know how a computer works. Types has a fixed memory layout and a set of CPU instructions that effectively can operate onpon that type.
In TypeScript can you cast a picture to an integer, in real typed language cannot you do it. This is what typesafety means, you should be able to trust the most basic primitives at least.
Correct me if am wrong here:
You stated that in typescript you can cast a picture to an integer.
Can you explain how can you do that in typescript?
Example: typescriptlang.org/play?#code/GYVw...
This was happening because your
cb()function returninganyvalue. That's why it's not recommended to useanytype.typescriptlang.org/play?#code/GYVw...
But if you do like this then you will get error:
typescriptlang.org/play?#code/FAMw...