-
Notifications
You must be signed in to change notification settings - Fork 1.7k
TypeScript errors in github/lib/github.d.ts #199
Description
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:
npm init -ytsc --init- Add
a.ts:
import * as x from "@actions/github"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:
- Update https://github.com/actions/toolkit/blob/master/packages/github/src/%40types/%40octokit/index.d.ts to better match the existing
@octokit/graphqldefinition - Add a dependency from
@actions/github->@octokit/graphql
Either way the import needs to be updated