From 828640ca263db2c95ed21e7353a2746fe6ac9fb8 Mon Sep 17 00:00:00 2001 From: SpaceEEC Date: Sat, 4 Apr 2020 14:11:59 +0200 Subject: [PATCH] ci(Testing): add TypeScript test job (#4002) * ci(Testing): add TypeScript job * chore: add eol before eof --- .github/tsc.json | 18 ++++++++++++++++++ .github/workflows/test-cron.yml | 21 +++++++++++++++++++++ .github/workflows/test.yml | 21 +++++++++++++++++++++ .gitignore | 1 + package.json | 1 + tsconfig.json | 12 +++++++++--- typings/index.ts | 28 ++++++++++++++++++++++++++++ 7 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 .github/tsc.json create mode 100644 typings/index.ts diff --git a/.github/tsc.json b/.github/tsc.json new file mode 100644 index 000000000..158f7e83d --- /dev/null +++ b/.github/tsc.json @@ -0,0 +1,18 @@ +{ + "problemMatcher": [ + { + "owner": "tsc", + "pattern": [ + { + "regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+),(\\d+)\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "code": 5, + "message": 6 + } + ] + } + ] +} diff --git a/.github/workflows/test-cron.yml b/.github/workflows/test-cron.yml index 10f97e38f..fec24cf69 100644 --- a/.github/workflows/test-cron.yml +++ b/.github/workflows/test-cron.yml @@ -39,6 +39,27 @@ jobs: - name: Run TSLint run: npm run lint:typings + typescript: + name: TypeScript + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install Node v12 + uses: actions/setup-node@v1 + with: + node-version: 12 + + - name: Install dependencies + run: npm install + + - name: Register Problem Matcher + run: echo "##[add-matcher].github/tsc.json" + + - name: Run TypeScript compiler + run: npm run test:typescript + docs: name: Documentation runs-on: ubuntu-latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6bdfc2967..6f0f5b31a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,6 +37,27 @@ jobs: - name: Run TSLint run: npm run lint:typings + typescript: + name: TypeScript + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install Node v12 + uses: actions/setup-node@v1 + with: + node-version: 12 + + - name: Install dependencies + run: npm install + + - name: Register Problem Matcher + run: echo "##[add-matcher].github/tsc.json" + + - name: Run TypeScript compiler + run: npm run test:typescript + docs: name: Documentation runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 55693512d..047170474 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ deploy/deploy_key.pub .tmp/ .vscode/ docs/docs.json +typings/index.js webpack/ diff --git a/package.json b/package.json index 75c2d27e4..625f863a9 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "types": "./typings/index.d.ts", "scripts": { "test": "npm run lint && npm run docs:test && npm run lint:typings", + "test:typescript": "tsc", "docs": "docgen --source src --custom docs/index.yml --output docs/docs.json", "docs:test": "docgen --source src --custom docs/index.yml", "lint": "eslint src", diff --git a/tsconfig.json b/tsconfig.json index 02c9ecc20..e0d4e91d3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,11 +5,17 @@ "declaration": false, "removeComments": false, "alwaysStrict": true, - "pretty": true, + "pretty": false, "module": "commonjs", "target": "es2019", - "lib": ["esnext", "esnext.array", "esnext.asynciterable", "esnext.intl", "esnext.symbol"], + "lib": [ + "esnext", + "esnext.array", + "esnext.asynciterable", + "esnext.intl", + "esnext.symbol" + ], "sourceMap": false, - "skipLibCheck": true + "skipDefaultLibCheck": true } } diff --git a/typings/index.ts b/typings/index.ts new file mode 100644 index 000000000..26708a4ca --- /dev/null +++ b/typings/index.ts @@ -0,0 +1,28 @@ +/// + +import { Client } from 'discord.js'; + +const client: Client = new Client(); + +client.on('ready', () => { + console.log(`Client is logged in as ${client.user!.tag} and ready!`); +}); + +client.on('guildCreate', g => { + const channel = g.channels.cache.random(); + if (!channel) return; + + channel.setName('foo').then(updatedChannel => { + console.log(`New channel name: ${updatedChannel.name}`); + }); +}); + +client.on('messageReactionRemoveAll', async message => { + console.log(`messageReactionRemoveAll - id: ${message.id} (${message.id.length})`); + + if (message.partial) message = await message.fetch(); + + console.log(`messageReactionRemoveAll - content: ${message.content}`); +}); + +client.login('absolutely-valid-token');