serverless/cloud

How to setup GitHub Actions

sangdth opened this issue · 1 comments

Currently I'm trying to bootstrap a project. It's just a starter typescript with demo /users.

My GitHub Action yaml:

name: Lint, TSCheck

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  main-jobs:
    name: Lint, TSCheck
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: 16

      - name: Install dependencies
        run: yarn install --frozen-lockfile --check-files

      - name: Linting
        run: yarn lint

      - name: Checking TypeScript
        run: yarn ts-check

The last step will return error like:

$ tsc --project tsconfig.json --noEmit
Error: index.ts(9,19): error TS2339: Property 'items' does not exist on type 'unknown'.
Error: node_modules/@serverless/cloud/types/api.d.ts(1,95): error TS230[7](https://github.com/getants/chatbot/runs/5435216007?check_suite_focus=true#step:6:7): Cannot find module 'express' or its corresponding type declarations.
Error: node_modules/@serverless/cloud/types/api.d.ts(2,35): error TS2307: Cannot find module 'express' or its corresponding type declarations.
Error: node_modules/@serverless/cloud/types/api.d.ts(3,24): error TS2307: Cannot find module 'multer' or its corresponding type declarations.
Error: node_modules/@serverless/cloud/types/api.d.ts(10,15): error TS2339: Property 'get' does not exist on type 'Router'.
Error: node_modules/@serverless/cloud/types/api.d.ts(11,16): error TS2339: Property 'post' does not exist on type 'Router'.
Error: node_modules/@serverless/cloud/types/api.d.ts(12,15): error TS2339: Property 'put' does not exist on type 'Router'.
Error: node_modules/@serverless/cloud/types/api.d.ts(13,1[8](https://github.com/getants/chatbot/runs/5435216007?check_suite_focus=true#step:6:8)): error TS233[9](https://github.com/getants/chatbot/runs/5435216007?check_suite_focus=true#step:6:9): Property 'delete' does not exist on type 'Router'.
Error: node_modules/@serverless/cloud/types/api.d.ts([14](https://github.com/getants/chatbot/runs/5435216007?check_suite_focus=true#step:6:14),17): error TS2339: Property 'patch' does not exist on type 'Router'.
Error: node_modules/@serverless/cloud/types/api.d.ts([15](https://github.com/getants/chatbot/runs/5435216007?check_suite_focus=true#step:6:15),19): error TS2339: Property 'options' does not exist on type 'Router'.
Error: node_modules/@serverless/cloud/types/api.d.ts([16](https://github.com/getants/chatbot/runs/5435216007?check_suite_focus=true#step:6:16),16): error TS2339: Property 'head' does not exist on type 'Router'.
Error: node_modules/@serverless/cloud/types/api.d.ts([17](https://github.com/getants/chatbot/runs/5435216007?check_suite_focus=true#step:6:17),15): error TS2339: Property 'use' does not exist on type 'Router'.

The tsconfig


{
  "compilerOptions": {
    "baseUrl": ".",
    "moduleResolution": "node"
  },
  "exclude": [".github", "node_modules"],
  "include": ["**/*.ts"]
}

Should I install those packages?

Sorry for the late reply. I was able to fix this with the following tsconfig.json:

{
  "compilerOptions": {
    "moduleResolution": "node",
    "skipLibCheck": true
  }
}

There is also a type error in index.ts that I fixed by adding as any to the data.get() call:

  let result = await data.get("user:*", true) as any;