Features of TypeScript - LearnHowToCode SarkariResult.com Interview Questions and Answers LearnHowToCodeOnline
Features of TypeScript:

Features of TypeScript



    Features of TypeScript

    1. The code written in typescript is compiled to the JavaScript for the purpose of execution.
    2. As we already discussed that the code written in typescript is compiled to the JavaScript which can reuse all of the existing JavaScript frameworks, tools, and libraries.
    3. As TypeScript is a superset of JavaScript so any valid .js file can be renamed to .ts and compiled with other TypeScript files.
    4. TypeScript is portable i.e. it can run on any environment that JavaScript runs on.
    5. TypeScript provides optional static typing. JavaScript is dynamically typed. This means JavaScript does not know what type a variable is until it is actually instantiated at run-time. This also means that it may be too late. TypeScript adds type support to JavaScript. TypeScript makes typing a bit easier and a lot less explicit by the usage of type inference. For example: var msg = “hello” in TypeScript is the same as var msg : string = “hello”. TLS (TypeScript Language Service) provides the facility to identify the type of the variable based on its value if it is declared with no type.
    6. TypeScript supports Object Oriented Programming concepts like classes, object, interfaces and inheritance etc.
    7. TypeScript Definition file with .d.ts extension provides definition for external JavaScript libraries.
    8. TypeScript provides strict null checks. TypeScript compiler will not allow undefined to be assigned to a variable unless you explicitly declare it to be of nullable type. For example, let num1 : number = undefined will result in a compile error. This fits perfectly with type theory, since undefined is not a number. One can define x to be a sum type of number and undefined to correct this: let num1 : number | undefined = undefined.
    9. Pragma comments are supported for specifying the source of a JSX factory in a file. JSX is an embeddable XML-like syntax supported by TypeScript; it can be transformed into JavaScript.
    10. Also, with JSX, the Element is resolved via the JSX factory. This capability is helpful when mixing and matching libraries such as React and Preact, or when mixing different versions of a library. At present, when JSX is used, TypeScript looks up a global JSX namespace for finding certain types. With Version 2.8, the compiler will try to look up the namespace based on the location of the JSX factory. Microsoft advises that going forward, new JSX-oriented libraries should avoid having JSX in the global scope. Instead, it should be exported from the respective factory function.
    11. Granular control on mapped type modifiers enables more explicit syntax for adding and removing modifiers in mapped types with the +and  operators.

    About Mariano

    I'm Ethan Mariano a software engineer by profession and reader/writter by passion.I have good understanding and knowledge of AngularJS, Database, javascript, web development, digital marketing and exploring other technologies related to Software development.

    0 comments:

    Featured post

    Political Full Forms List

    Acronym Full Form MLA Member of Legislative Assembly RSS Really Simple Syndication, Rashtriya Swayamsevak Sangh UNESCO United Nations E...

    Powered by Blogger.