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

Correct generic type argument order for ObjectTypeExtension sqlTable thunk #454

Merged
merged 1 commit into from
May 20, 2021

Conversation

airhorns
Copy link
Collaborator

@airhorns airhorns commented May 20, 2021

Description

I think I screwed this up in #418. We unthunk passing the context as the second argument here like we do everywhere else:

const sqlTable = unthunk(config.sqlTable, sqlASTNode.args || {}, context)
. Confusingly, the ThunkWithArgsCtx takes the type arguments in a different order than the function it represents, but I think it's not worth causing a breaking change to make these aligned.

Testing

Can be tested by running npm run testtsd

  • This change adds test coverage for new/changed/fixed functionality

Checklist

  • I have added documentation for new/changed functionality in this PR via comments and by updating the change log
  • All active GitHub checks for tests, formatting, and security are passing

…thunk

I think I screwed this up in join-monster#418. We unthunk passing the context as the second argument here like we do everywhere else: https://github.com/join-monster/join-monster/blob/73ef3473713bf88e955188ec888a8a0540cabef6/src/query-ast-to-sql-ast/index.js#L275 . Confusingly, the `ThunkWithArgsCtx` takes the type arguments in a different order than the function it represents, but I think it's not worth causing a breaking change to make these aligned.
@lorensr
Copy link
Member

lorensr commented May 20, 2021

Thanks for the fix! Any idea why it's failing for me? 😄

join-monster git:(upstream ⚡ gadget-inc-ts-fix-thunk-argument-order) $ npm run testtsd

> join-monster@3.0.2 testtsd
> npm run build && tsd


> join-monster@3.0.2 build
> rm -rf dist && babel src --no-comments --out-dir dist --copy-files --ignore README.md

Successfully compiled 17 files with Babel (1529ms).

  test-d/index.test-d.ts:30:8
  ✖   30:8   Parameter type ExampleContext is not identical to argument type any.                                                                 
  ✖   63:20  Parameter table implicitly has an any type.                                                                                          
  ✖   63:27  Parameter args implicitly has an any type.                                                                                           
  ✖   63:33  Parameter context implicitly has an any type.                                                                                        
  ✖   64:12  Parameter type string is not identical to argument type any.                                                                         
  ✖   65:12  Parameter type ExampleArgs is not identical to argument type any.                                                                    
  ✖   66:12  Parameter type ExampleContext is not identical to argument type any.                                                                 
  ✖   69:20  Parameter table1 implicitly has an any type.                                                                                         
  ✖   69:28  Parameter table2 implicitly has an any type.                                                                                         
  ✖   69:36  Parameter args implicitly has an any type.                                                                                           
  ✖   69:42  Parameter context implicitly has an any type.                                                                                        
  ✖   70:12  Parameter type string is not identical to argument type any.                                                                         
  ✖   71:12  Parameter type string is not identical to argument type any.                                                                         
  ✖   72:12  Parameter type ExampleArgs is not identical to argument type any.                                                                    
  ✖   73:12  Parameter type ExampleContext is not identical to argument type any.                                                                 
  ✖   77:18  Parameter table implicitly has an any type.                                                                                          
  ✖   77:25  Parameter args implicitly has an any type.                                                                                           
  ✖   77:31  Parameter context implicitly has an any type.                                                                                        
  ✖   78:12  Parameter type string is not identical to argument type any.                                                                         
  ✖   79:12  Parameter type ExampleArgs is not identical to argument type any.                                                                    
  ✖   80:12  Parameter type ExampleContext is not identical to argument type any.                                                                 
  ✖   97:18  Parameter args implicitly has an any type.                                                                                           
  ✖   97:24  Parameter context implicitly has an any type.                                                                                        
  ✖   98:12  Parameter type ExampleArgs is not identical to argument type any.                                                                    
  ✖   99:12  Parameter type ExampleContext is not identical to argument type any.                                                                 
  ✖  102:20  Parameter args implicitly has an any type.                                                                                           
  ✖  102:26  Parameter context implicitly has an any type.                                                                                        
  ✖  103:12  Parameter type ExampleArgs is not identical to argument type any.                                                                    
  ✖  104:12  Parameter type ExampleContext is not identical to argument type any.                                                                 
  ✖  110:20  Parameter args implicitly has an any type.                                                                                           
  ✖  110:26  Parameter context implicitly has an any type.                                                                                        
  ✖  111:12  Parameter type ExampleArgs is not identical to argument type any.                                                                    
  ✖  112:12  Parameter type ExampleContext is not identical to argument type any.                                                                 
  ✖  134:17  Parameter accountTable implicitly has an any type.                                                                                   
  ✖  148:24  Parameter table1 implicitly has an any type.                                                                                         
  ✖  148:32  Parameter table2 implicitly has an any type.                                                                                         
  ✖  148:40  Parameter args implicitly has an any type.                                                                                           
  ✖  148:46  Parameter context implicitly has an any type.                                                                                        
  ✖  149:16  Parameter type string is not identical to argument type any.                                                                         
  ✖  150:16  Parameter type string is not identical to argument type any.                                                                         
  ✖  161:15  Parameter followerTable implicitly has an any type.                                                                                  
  ✖  161:30  Parameter junctionTable implicitly has an any type.                                                                                  
  ✖  161:45  Parameter args implicitly has an any type.                                                                                           
  ✖  161:51  Parameter context implicitly has an any type.                                                                                        
  ✖  162:16  Parameter type string is not identical to argument type any.                                                                         
  ✖  163:16  Parameter type string is not identical to argument type any.                                                                         
  ✖  164:16  Parameter type ExampleArgs is not identical to argument type any.                                                                    
  ✖  165:16  Parameter type ExampleContext is not identical to argument type any.                                                                 
  ✖  168:15  Parameter junctionTable implicitly has an any type.                                                                                  
  ✖  168:30  Parameter followeeTable implicitly has an any type.                                                                                  
  ✖  168:45  Parameter args implicitly has an any type.                                                                                           
  ✖  168:51  Parameter context implicitly has an any type.                                                                                        
  ✖  169:16  Parameter type string is not identical to argument type any.                                                                         
  ✖  170:16  Parameter type string is not identical to argument type any.                                                                         
  ✖  171:16  Parameter type ExampleArgs is not identical to argument type any.                                                                    
  ✖  172:16  Parameter type ExampleContext is not identical to argument type any.                                                                 
  ✖  191:17  Parameter accountTable implicitly has an any type.                                                                                   
  ✖  193:23  Parameter args implicitly has an any type.                                                                                           
  ✖  193:29  Parameter context implicitly has an any type.                                                                                        
  ✖  194:14  Parameter type ExampleArgs is not identical to argument type any.                                                                    
  ✖  195:14  Parameter type ExampleContext is not identical to argument type any.                                                                 
  ✖  198:22  Parameter args implicitly has an any type.                                                                                           
  ✖  198:28  Parameter context implicitly has an any type.                                                                                        
  ✖  199:14  Parameter type ExampleArgs is not identical to argument type any.                                                                    
  ✖  200:14  Parameter type ExampleContext is not identical to argument type any.                                                                 
  ✖  206:22  Parameter args implicitly has an any type.                                                                                           
  ✖  206:28  Parameter context implicitly has an any type.                                                                                        
  ✖  207:14  Parameter type ExampleArgs is not identical to argument type any.                                                                    
  ✖  208:14  Parameter type ExampleContext is not identical to argument type any.                                                                 
  ✖  214:22  Parameter args implicitly has an any type.                                                                                           
  ✖  214:28  Parameter context implicitly has an any type.                                                                                        
  ✖  215:14  Parameter type ExampleArgs is not identical to argument type any.                                                                    
  ✖  216:14  Parameter type ExampleContext is not identical to argument type any.                                                                 
  ✖  224:20  Parameter junctionTable implicitly has an any type.                                                                                  
  ✖  224:35  Parameter args implicitly has an any type.                                                                                           
  ✖  224:41  Parameter context implicitly has an any type.                                                                                        
  ✖  225:14  Parameter type string is not identical to argument type any.                                                                         
  ✖  226:14  Parameter type ExampleArgs is not identical to argument type any.                                                                    
  ✖  227:14  Parameter type ExampleContext is not identical to argument type any.                                                                 

  node_modules/graphql/type/definition.d.ts:373:17
  ✖  373:17  All declarations of GraphQLObjectTypeExtensions must have identical type parameters.                                                 
  ✖  503:17  All declarations of GraphQLFieldExtensions must have identical type parameters.                                                      
  ✖  523:13  Generic type GraphQLFieldExtensions<TSource, TContext, TArgs, _TSource, _TContext, _TArgs> requires between 5 and 6 type arguments.  
  ✖  570:29  Generic type GraphQLFieldExtensions<TSource, TContext, TArgs, _TSource, _TContext, _TArgs> requires between 5 and 6 type arguments.  

  dist/index.d.ts:104:12
  ✖  104:12  All declarations of GraphQLObjectTypeExtensions must have identical type parameters.                                                 
  ✖  107:12  All declarations of GraphQLFieldExtensions must have identical type parameters.                                                      

  85 errors

@airhorns
Copy link
Collaborator Author

Maybe your tsd version locally? I have this output for npm why tsd

inspector ~/C/join-monster (gadget-hacks) ➜  npm why tsd
tsd@0.13.1 dev
node_modules/tsd
  dev tsd@"^0.13.1" from the root project

@lorensr lorensr merged commit 028fba5 into join-monster:master May 20, 2021
@airhorns airhorns deleted the ts-fix-thunk-argument-order branch May 20, 2021 19:32
@lorensr
Copy link
Member

lorensr commented May 20, 2021

Released in 3.0.3

Maybe your tsd version locally? I have this output for npm why tsd

I had same output. It started passing after I switched from Node 12 to 10 and re-ran npm i. But now it also works in 12, so 🤷‍♂️

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 this pull request may close these issues.

None yet

2 participants