Typescript Simple
My entry into typescript was through React. There you use these bootstrapping tools and they create loads of things for you that a tutorial then explains what it is.
But what is actually the minimum Typescript
setup? And maybe first. What is Typescript? Typescript is a superset of Javascript. It works by transpiling your code into Javascript code. The tool that does this is called tsc
. You can install tsc
on your computer by running npm i -g typescript
. This command might need to run as root, you can see my previous blog entry on how to not have to run it as root.
Once you have tsc
you can run tsc --init
. This creates a minimum tsconfig.json
file which contains the rules for how the typescript transpiler should work. By default it will try to compile code any .ts
file it finds in the folder where you are at.
It makes sense to edit the tsconfig.json, but it’s good to know that you don’t really need more commands than
npm i -g typescript
tsc
to compile and use typescript.