From 375667170bc5fb3f9c3c74d31590987332b433e6 Mon Sep 17 00:00:00 2001 From: Masaya Nakamura Date: Sat, 25 Sep 2021 02:16:51 +0900 Subject: [PATCH 1/5] ci: run type check on GitHub Actions --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58e4f9c..26c3b19 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,10 @@ jobs: node-version: "14.x" - run: npm ci - run: npm run lint:ci + - name: Type check + uses: gozala/typescript-error-reporter-action@v1.0.5 + with: + project: functions/tsconfig.json - name: Create serviceAccountKey.json for online testing run: echo "$SERVICE_ACCOUNT_KEY_JSON" > ../serviceAccountKey.json env: From ca5aea5912b9d89a5996ff0f84036ec1bbde5149 Mon Sep 17 00:00:00 2001 From: Masaya Nakamura Date: Sat, 25 Sep 2021 02:42:22 +0900 Subject: [PATCH 2/5] chore: remove @types/jest, in favor of @jest/globals https://dev.to/kengotoda/how-to-replace-types-jest-with-jest-globals-and-jest-mock-52mb --- functions/package-lock.json | 208 ------------------ functions/package.json | 1 - functions/src/__tests__/index.test.ts | 10 +- .../src/model/__tests__/rotation.test.ts | 2 +- 4 files changed, 10 insertions(+), 211 deletions(-) diff --git a/functions/package-lock.json b/functions/package-lock.json index 43b29a4..07a220f 100644 --- a/functions/package-lock.json +++ b/functions/package-lock.json @@ -1230,70 +1230,6 @@ } } }, - "@jest/types": { - "version": "25.5.0", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-25.5.0.tgz", - "integrity": "sha512-OXD0RgQ86Tu3MazKo8bnrkDRaDXXMGUqd+kTtLtK1Zb7CRzQcaSRPPPV37SvYTdevXEBVxe0HXylEjs8ibkmCw==", - "dev": true, - "requires": { - "@types/istanbul-lib-coverage": "^2.0.0", - "@types/istanbul-reports": "^1.1.1", - "@types/yargs": "^15.0.0", - "chalk": "^3.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", - "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", - "dev": true, - "requires": { - "@types/color-name": "^1.1.1", - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", - "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", - "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, "@protobufjs/aspromise": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", @@ -1675,26 +1611,6 @@ "@types/istanbul-lib-coverage": "*" } }, - "@types/istanbul-reports": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-1.1.2.tgz", - "integrity": "sha512-P/W9yOX/3oPZSpaYOCQzGqgCQRXn0FFO/V8bWrCQs+wLmvVVxk6CRBXALEvNs9OHIatlnlFokfhuDo2ug01ciw==", - "dev": true, - "requires": { - "@types/istanbul-lib-coverage": "*", - "@types/istanbul-lib-report": "*" - } - }, - "@types/jest": { - "version": "26.0.9", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-26.0.9.tgz", - "integrity": "sha512-k4qFfJ5AUKrWok5KYXp2EPm89b0P/KZpl7Vg4XuOTVVQEhLDBDBU3iBFrjjdgd8fLw96aAtmnwhXHl63bWeBQQ==", - "dev": true, - "requires": { - "jest-diff": "^25.2.1", - "pretty-format": "^25.2.1" - } - }, "@types/json-schema": { "version": "7.0.5", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.5.tgz", @@ -1820,15 +1736,6 @@ "@types/node": "*" } }, - "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", - "dev": true, - "requires": { - "@types/yargs-parser": "*" - } - }, "@types/yargs-parser": { "version": "15.0.0", "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-15.0.0.tgz", @@ -2955,12 +2862,6 @@ "streamsearch": "0.1.2" } }, - "diff-sequences": { - "version": "25.2.6", - "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-25.2.6.tgz", - "integrity": "sha512-Hq8o7+6GaZeoFjtpgvRBUknSXNeJiCx7V9Fr94ZMljNiCr9n9L8H8aJqgWOQiDDGdyn29fRNcDdRVJ5fdyihfg==", - "dev": true - }, "doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", @@ -5075,70 +4976,6 @@ } } }, - "jest-diff": { - "version": "25.5.0", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-25.5.0.tgz", - "integrity": "sha512-z1kygetuPiREYdNIumRpAHY6RXiGmp70YHptjdaxTWGmA085W3iCnXNx0DhflK3vwrKmrRWyY1wUpkPMVxMK7A==", - "dev": true, - "requires": { - "chalk": "^3.0.0", - "diff-sequences": "^25.2.6", - "jest-get-type": "^25.2.6", - "pretty-format": "^25.5.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", - "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", - "dev": true, - "requires": { - "@types/color-name": "^1.1.1", - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", - "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", - "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, "jest-docblock": { "version": "27.0.6", "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-27.0.6.tgz", @@ -5319,12 +5156,6 @@ } } }, - "jest-get-type": { - "version": "25.2.6", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-25.2.6.tgz", - "integrity": "sha512-DxjtyzOHjObRM+sM1knti6or+eOgcGU4xVSb2HNP1TqO4ahsT+rqZg+nyqHWJSvWgKC5cG3QjGFBqxLghiF/Ig==", - "dev": true - }, "jest-haste-map": { "version": "27.2.0", "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-27.2.0.tgz", @@ -7256,45 +7087,6 @@ "fast-diff": "^1.1.2" } }, - "pretty-format": { - "version": "25.5.0", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-25.5.0.tgz", - "integrity": "sha512-kbo/kq2LQ/A/is0PQwsEHM7Ca6//bGPPvU6UnsdDRSKTWxT/ru/xb88v4BJf6a69H+uTytOEsTusT9ksd/1iWQ==", - "dev": true, - "requires": { - "@jest/types": "^25.5.0", - "ansi-regex": "^5.0.0", - "ansi-styles": "^4.0.0", - "react-is": "^16.12.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", - "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", - "dev": true, - "requires": { - "@types/color-name": "^1.1.1", - "color-convert": "^2.0.1" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - } - } - }, "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", diff --git a/functions/package.json b/functions/package.json index fab0a16..0d1a437 100644 --- a/functions/package.json +++ b/functions/package.json @@ -26,7 +26,6 @@ }, "devDependencies": { "@slack-wrench/jest-mock-web-client": "^1.2.0", - "@types/jest": "^26.0.9", "@types/supertest": "^2.0.10", "@typescript-eslint/eslint-plugin": "^3.8.0", "@typescript-eslint/parser": "^3.8.0", diff --git a/functions/src/__tests__/index.test.ts b/functions/src/__tests__/index.test.ts index e166c73..fb7dec8 100644 --- a/functions/src/__tests__/index.test.ts +++ b/functions/src/__tests__/index.test.ts @@ -1,4 +1,12 @@ -import { describe, it, expect } from "@jest/globals"; +import { + afterAll, + beforeEach, + afterEach, + describe, + it, + expect, + jest, +} from "@jest/globals"; import { MockedWebClient, MockWebClient, diff --git a/functions/src/model/__tests__/rotation.test.ts b/functions/src/model/__tests__/rotation.test.ts index 27fd2a7..c54df07 100644 --- a/functions/src/model/__tests__/rotation.test.ts +++ b/functions/src/model/__tests__/rotation.test.ts @@ -1,4 +1,4 @@ -import { describe, it, expect } from "@jest/globals"; +import { describe, it, expect, jest } from "@jest/globals"; import { Rotation } from "../rotation"; describe("Rotation", () => { From 8ef881df6224d78dd78069a9c8ddcd2c1d418fb6 Mon Sep 17 00:00:00 2001 From: Masaya Nakamura Date: Sat, 25 Sep 2021 02:44:34 +0900 Subject: [PATCH 3/5] try --- functions/src/slack.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/src/slack.ts b/functions/src/slack.ts index 03b581f..6fcf4e1 100644 --- a/functions/src/slack.ts +++ b/functions/src/slack.ts @@ -43,7 +43,7 @@ export const createSlackApp = ( }); // 型定義上は optional だが、正常系では必ず存在するはず // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - return json.members!.reduce>( + return json.members.reduce>( (acc, { id, profile }) => ({ ...acc, // eslint-disable-next-line @typescript-eslint/no-non-null-assertion From 734cd08125a7e4985114107c17b5839312a75790 Mon Sep 17 00:00:00 2001 From: Masaya Nakamura Date: Sat, 25 Sep 2021 02:46:33 +0900 Subject: [PATCH 4/5] Revert "try" This reverts commit 8ef881df6224d78dd78069a9c8ddcd2c1d418fb6. --- functions/src/slack.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/src/slack.ts b/functions/src/slack.ts index 6fcf4e1..03b581f 100644 --- a/functions/src/slack.ts +++ b/functions/src/slack.ts @@ -43,7 +43,7 @@ export const createSlackApp = ( }); // 型定義上は optional だが、正常系では必ず存在するはず // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - return json.members.reduce>( + return json.members!.reduce>( (acc, { id, profile }) => ({ ...acc, // eslint-disable-next-line @typescript-eslint/no-non-null-assertion From fd51a1fd18d8673b98e10b6e2760470a70fbe7e4 Mon Sep 17 00:00:00 2001 From: Masaya Nakamura Date: Sat, 25 Sep 2021 02:53:35 +0900 Subject: [PATCH 5/5] chore: add an npm script to check types --- functions/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/package.json b/functions/package.json index 0d1a437..e4277f6 100644 --- a/functions/package.json +++ b/functions/package.json @@ -9,6 +9,7 @@ "logs": "firebase functions:log", "lint": "eslint --format codeframe --ext .js,.jsx,.ts,.tsx .", "lint:ci": "npm run lint -- --max-warnings=0", + "type": "tsc --noEmit", "test": "jest", "test:ci": "npm run test -- --ci" },