Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types for SchemaDirectiveVisitor.visitSchemaDirectives broken in 5.0.0 branch #1376

Closed
DrewML opened this issue Apr 20, 2020 · 5 comments · Fixed by #1378
Closed

Types for SchemaDirectiveVisitor.visitSchemaDirectives broken in 5.0.0 branch #1376

DrewML opened this issue Apr 20, 2020 · 5 comments · Fixed by #1378

Comments

@DrewML
Copy link

DrewML commented Apr 20, 2020

To start with, congratulations on the big 5.0.0 release, and thank you for all the hard work!

I upgraded from 4.x.x, and it looks like the current typings aren't working as intended for one small thing.

Minimal Repro

SchemaDirectiveVisitor.visitSchemaDirectives(anyGQLSchema, {
    foo: class extends SchemaDirectiveVisitor {},
});
Type 'typeof foo' is 
not assignable to type 'typeof SchemaDirectiveVisitor'. 
Construct signature return types 'foo' and 'SchemaDirectiveVisitor<TArgs, TContext>' are incompatible.
    The types of 'context' are incompatible between these types.
      Type '{ [key: string]: any; }' is not assignable to type 'TContext'.
        '{ [key: string]: any; }' is assignable to the constraint of type 'TContext', but 'TContext' could be instantiated with a different subtype of constraint '{}'.

	foo: class extends SchemaDirectiveVisitor {},

Testing

I pulled down the repo locally and ran ./node_modules/.bin/tsc, and noticed that the same compiler errors are also happening in master.

It looks like this likely wasn't caught by the unit tests because diagnostics are disabled in ts-jest.

The issue can be seen by running tsc against src/test/directives.test.ts:

image

@yaacovCR
Copy link
Collaborator

Thanks so much for the wonderful reproduction!

@yaacovCR yaacovCR reopened this Apr 21, 2020
@yaacovCR yaacovCR added the waiting-for-release Fixed/resolved, and waiting for the next stable release label Apr 21, 2020
yaacovCR added a commit that referenced this issue Apr 21, 2020
= Use Record instead of { [key: string]: <whatever> } when possible.
= Use any for SchemaDirectiveVisitor generic default, a simpler attempt at #1376
= Add typescript check, as rollup seems to fail only on semantic/syntax errors, not type errors
yaacovCR added a commit that referenced this issue Apr 21, 2020
= Use Record instead of { [key: string]: <whatever> } when possible.
= Use any for SchemaDirectiveVisitor generic default, a simpler attempt at #1376
= Add typescript check, as rollup seems to fail only on semantic/syntax errors, not type errors
@DrewML
Copy link
Author

DrewML commented Apr 21, 2020

That was impressively fast @yaacovCR - I really appreciate you helping out!

yaacovCR added a commit that referenced this issue Apr 21, 2020
Until we figure out why rollup not failing, see #1376

Note that these github actions appear to only test graphql-tools with graphql v15
@yaacovCR
Copy link
Collaborator

Thanks again for awesome reproduction.

Hoping to get a canary build out for you to test when #1368 lands.

@yaacovCR
Copy link
Collaborator

Also available with latest alpha, npm install graphql-tools@alpha.

@yaacovCR
Copy link
Collaborator

Closed by #1419.

@yaacovCR yaacovCR removed the waiting-for-release Fixed/resolved, and waiting for the next stable release label May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants