TypeScript

As seen in the first post, typescript was used for the development of this blog, but what is typescript? basically typescript is statically typed javascript for variables and additional resources to help development, it was created in 2012 by microsoft, what differs typescript from javascript is that browsers do not support typescript, which before being "read" by browsers it is "transpiled" to javascript so the browser can run the script.

 

Examples javascript in typescript:

 

Variables

script.js
var name = "João Pedro"

script.ts
var name: string = "João Pedro"

Functions

script.js
function helloWorld(message){
return message
}
console.log(helloWorld("Hello World!"))

script.ts
function helloWorld(message: string): string /*Function return*/{
return message
}
console.log(helloWorld("Hello World!"))


Typescript also contains several other things that javascript doesn't have that help in development like Enums, Tuples, Interface, Namespaces, Generics, Decorators etc.

This post contains only extremely basic content about typescript if you really want to learn typescript I recommend reading the typescript documentation: https://www.typescriptlang.org/docs/


Updated At: 5/27/2023

← Back to home