maxkomarychev / merge-pal-action

GitHub Action that automatically merges your pull request!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue compiling typescript

gpambrozio opened this issue · comments

I created a fork of this repo and am trying to customize the scripts for my use case and I'm having trouble compiling the typescript files.

I have never used typescript before so I'm probably missing some setup step. I have looked online but can't find any resources on how to setup an existing project, just how to create a new one.

What I've done so far:

  • run npm install --save-dev
  • run ./node_modules/.bin/tsc

What I get is this:

node_modules/@actions/github/lib/github.d.ts:5:37 - error TS2507: Type 'typeof import("/Users/gustavoambrozio/Development/merge-pal-action/node_modules/@octokit/rest/index")' is not a constructor function type.

5 export declare class GitHub extends Octokit {
                                      ~~~~~~~

node_modules/@actions/github/lib/github.d.ts:7:52 - error TS2694: Namespace '"/Users/gustavoambrozio/Development/merge-pal-action/node_modules/@octokit/rest/index"' has no exported member 'Options'.

7     constructor(token: string, opts?: Omit<Octokit.Options, 'auth'>);
                                                     ~~~~~~~

src/canMerge.ts:3:49 - error TS2694: Namespace '"/Users/gustavoambrozio/Development/merge-pal-action/node_modules/@octokit/rest/index"' has no exported member 'PullsGetResponse'.

3 export function canMergeByMergeable(pr: Octokit.PullsGetResponse) {
                                                  ~~~~~~~~~~~~~~~~

src/canMerge.ts:6:54 - error TS2694: Namespace '"/Users/gustavoambrozio/Development/merge-pal-action/node_modules/@octokit/rest/index"' has no exported member 'PullsGetResponse'.

6 export function canMergeByMergeableState(pr: Octokit.PullsGetResponse) {
                                                       ~~~~~~~~~~~~~~~~

src/canMerge.ts:10:17 - error TS2694: Namespace '"/Users/gustavoambrozio/Development/merge-pal-action/node_modules/@octokit/rest/index"' has no exported member 'PullsGetResponse'.

10     pr: Octokit.PullsGetResponse,
                   ~~~~~~~~~~~~~~~~

src/isEnabledForPR.ts:3:17 - error TS2694: Namespace '"/Users/gustavoambrozio/Development/merge-pal-action/node_modules/@octokit/rest/index"' has no exported member 'PullsGetResponse'.

3     pr: Octokit.PullsGetResponse | Octokit.PullsListResponseItem,
                  ~~~~~~~~~~~~~~~~

src/isEnabledForPR.ts:3:44 - error TS2694: Namespace '"/Users/gustavoambrozio/Development/merge-pal-action/node_modules/@octokit/rest/index"' has no exported member 'PullsListResponseItem'.

3     pr: Octokit.PullsGetResponse | Octokit.PullsListResponseItem,
                                             ~~~~~~~~~~~~~~~~~~~~~

src/mergeIfReady.ts:13:29 - error TS2339: Property 'pulls' does not exist on type 'GitHub'.

13     const pr = await client.pulls.get({
                               ~~~~~

src/mergeIfReady.ts:29:22 - error TS2339: Property 'pulls' does not exist on type 'GitHub'.

29         await client.pulls.merge({
                        ~~~~~

src/pushHandler.ts:13:36 - error TS2339: Property 'pulls' does not exist on type 'GitHub'.

13     const openedPrs = await client.pulls.list({
                                      ~~~~~

src/pushHandler.ts:26:24 - error TS2339: Property 'pulls' does not exist on type 'GitHub'.

26             if (client.pulls.updateBranch({
                          ~~~~~

src/statusHandler.ts:14:20 - error TS2339: Property 'pulls' does not exist on type 'GitHub'.

14             client.pulls.list({
                      ~~~~~


Found 12 errors.

I'd appreciate any help in getting me started on this. And thanks for creating this action!

Cheers,
Gustavo

As reference if someone else is interested, to get this to compile for me I had to change a lot of places that had import Octokit = require('@octokit/rest') and change it to import { Octokit } from '@octokit/rest', including in code that is in node_modules. I also uncommented "allowSyntheticDefaultImports": true in tsconfig.json

hey @gpambrozio, package.json includes script "build" which you can run with npm run build or yarn build in order to produce runnable version in a single file