What TypeScript actually?
- Most of the feature is already included from es6 and es7, things like classes and arrow functions. So the main reason to use TypeScript is static types.
Dynamic and Static Types
In the programming world, you have dynamically typed languages and you have statically typed languages
Dynamic types languages
Static Types languages
Statically Typed Languages you explicitly assign types to variables, whether that’s a string, Boolean, number, functions parameter, functions return value can also have types as well, etc.
So you will declare types as well, so you declared the same name variables as a string so statically types languages. Some static-typed languages are JAVA, C, C++, Rust, Go,
Pros and Cons of TypeScript
|More code to write
|Easily spot bug
|More to learn
|Not true static typing
- TypeScript makes your code more robust as all variables type defined and this also easily spots bugs in as early stage, that you may miss if you are not using types.
- Apparently, research has found that typescript detects about 15 % of common bugs at the compiled stage. Readability is also a good feature especially.
- Type script uses .ts and .tsx extensions for working with JSX, Like you are working with react component
- TSC can watch files and reports error at the compile time.
- Many tools include TS compilation by default with needs extra setup for that.
- Most IDE have greater support for TS
- The ts.config file is used to configure how TypeScipts will work. You can create or generate ts.config file to control how TypeDcript works.
Let learn TypeScript
I think that is enough detail to start working on Typescripts. Let’s move on VSCode with spend much time. All right so first thing we can do install the typescripts compiler.
That we can do this with NPM and yarn and also you can install it globally so it will work with hole system or locally in the project. Will continue this article will some example
The code should be more expressive, and you can see what going on. If you building simple react applications only then TypeScript is unnecessary stuff, But does my opinion, Of course, you welcome to disagree with that. Thanks for coding with me. Thank You