-
Create a new directory
first-firestoreand then change your current directory there -
Initialize a Node project (do the following while you are inside the new directory created in (#1))
yarn init #npm init -
Update
package.jsonto enable ES6 module import/export{ "type": "module", } -
Add typescript as a new project dependency
yarn add typescript # TS compiler yarn add tsx # TS execution environment for NodeJS -
Install TypeScript globally
yarn global add typescript # npm install -g typescript -
Create
tsconfig.json:{ "compilerOptions": { "target": "ESNext", "module": "ESNext", "sourceMap": true } }To enable top-level await:
targetmust be set to "ES2017" or highermodulemust be set to "ES2022" or higher
-
Create a "Hello World" program in TypeScript
// hello.ts console.info("Hello world!")
-
Run the above program
npx tsx hello.ts
Setup Firebase Project (https://firebase.google.com)
-
Create a new Project
- Initialize a new Firestore
- Create a new Web App under the project created in (#1)
-
Add Firebase as another dependency to project in (#1)
yarn add firebase yarn list firebase # Optional: confirm version 11.x (or newer) -
Run each sample program
npx tsx 01-hello-firestore.ts