Skip to content

TypeScript errors in github/lib/github.d.ts #199

@RyanCavanaugh

Description

@RyanCavanaugh

Describe the bug

The shipped github.d.ts file contains errors. The originating code is here: https://github.com/actions/toolkit/blob/master/packages/github/src/github.ts

To Reproduce
Steps to reproduce the behavior:

  1. npm init -y
  2. tsc --init
  3. Add a.ts:
import * as x from "@actions/github"
  1. tsc

Result:

node_modules/@actions/github/lib/github.d.ts:1:49 - error TS7016: Could not find a declaration file for module '@octokit/graphql'. 'D:/Throwaway/IssuesTest/node_modules/@octokit/graphql/index.js' implicitly has an 'any' type.
  Try `npm install @types/octokit__graphql` if it exists or add a new declaration (.d.ts) file containing `declare module '@octokit/graphql';`

1 import { GraphQlQueryResponse, Variables } from '@octokit/graphql';
                                                  ~~~~~~~~~~~~~~~~~~

Expected behavior

There shouldn't be errors

Screenshots

Desktop (please complete the following information):

  • OS: I'm on Windows

Additional context

This is a very confusing error because the next logical step for a developer would be to npm install @octokit/graphql, but if you do this, it just changes the error:

node_modules/@actions/github/lib/github.d.ts:1:10 - error TS2305: Module '"../../../../../../Throwaway/IssuesTest/node_modules/@octokit/graphql/dist-types"' has no exported member 'GraphQlQueryResponse'.

1 import { GraphQlQueryResponse, Variables } from '@octokit/graphql';
           ~~~~~~~~~~~~~~~~~~~~

node_modules/@actions/github/lib/github.d.ts:1:32 - error TS2305: Module '"../../../../../../Throwaway/IssuesTest/node_modules/@octokit/graphql/dist-types"' has no exported member 'Variables'.

1 import { GraphQlQueryResponse, Variables } from '@octokit/graphql';
                                 ~~~~~~~~~

It wasn't clear to me why the .ts file loads the checked-in .d.ts instead of just pulling in the real @octokit/grapqhl module? This pattern is guaranteed to break for .d.ts emit unless some other source of type data provides a definition for the module.

Two possible fixes:

Either way the import needs to be updated

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions