A short tutorial on how to create a basic TypeScript app for a game or another project targeted on frontend.
Create a new folder for your project and cd
there and type npm init
to create package.json
.
Writer whatever you want there or just hit enter to each and then let's install typescript: npm i -S typescript
.
We could install it also globally for some ease of use BUT to me installing global dependencies are annoying so for now let's withold from doing so.
Instead let's add tsconfig.json
manually to the root of our folder. This would be created with tsc --init
but since we are now very stupid we'll do it manually. Copy & paste this inside of it:
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"noImplicitAny": false,
"sourceMap": false
}
}
And there we go, now we have setup our project with TypeScript. Nothing to compile yet, but we're getting there next.
Without any .ts
files our project would be pretty awful so let's create some for our app. First create src
folder to your root and then add file index.ts
inside of it. This file will serve as an entry to our project and exposes the API outside for others to use.
Copy & paste this inside of it: