1- // @ts -nocheck
21/**
32 * Copyright (c) 2019 GraphQL Contributors
43 * All rights reserved.
@@ -16,15 +15,12 @@ import {
1615 GraphQLType ,
1716 GraphQLCompositeType ,
1817 GraphQLEnumValue ,
19- Kind ,
20- KindEnum ,
2118 GraphQLField ,
19+ GraphQLFieldMap ,
2220} from 'graphql' ;
2321
2422import {
2523 CompletionItem ,
26- ContextToken ,
27- State ,
2824 AllTypeInfo ,
2925 Position ,
3026} from 'graphql-language-service-types' ;
@@ -49,7 +45,8 @@ import {
4945import {
5046 CharacterStream ,
5147 onlineParser ,
52- RuleKind ,
48+ ContextToken ,
49+ State ,
5350 RuleKinds ,
5451} from 'graphql-language-service-parser' ;
5552
@@ -116,7 +113,7 @@ export function getAutocompleteSuggestions(
116113 argDefs . map ( argDef => ( {
117114 label : argDef . name ,
118115 detail : String ( argDef . type ) ,
119- documentation : argDef . description ,
116+ documentation : argDef . description ?? undefined ,
120117 kind : CompletionItemKind . Variable ,
121118 } ) ) ,
122119 ) ;
@@ -139,7 +136,7 @@ export function getAutocompleteSuggestions(
139136 objectFields . map ( field => ( {
140137 label : field . name ,
141138 detail : String ( field . type ) ,
142- documentation : field . description ,
139+ documentation : field . description ?? undefined ,
143140 kind : completionKind ,
144141 } ) ) ,
145142 ) ;
@@ -207,13 +204,17 @@ function getSuggestionsForFieldNames(
207204 token : ContextToken ,
208205 typeInfo : AllTypeInfo ,
209206 schema : GraphQLSchema ,
210- kind : RuleKind . SelectionSet | RuleKind . Field | RuleKind . AliasedField ,
207+ // kind: RuleKind.SelectionSet | RuleKind.Field | RuleKind.AliasedField,
208+ _kind : string ,
211209) : Array < CompletionItem > {
212210 if ( typeInfo . parentType ) {
213211 const parentType = typeInfo . parentType ;
214212 let fields : GraphQLField < null , null > [ ] = [ ] ;
215213 if ( 'getFields' in parentType ) {
216- fields = objectValues < GraphQLField < null , null > > ( parentType . getFields ( ) ) ;
214+ fields = objectValues < GraphQLField < null , null > > (
215+ // TODO: getFields returns `GraphQLFieldMap<any, any> | GraphQLInputFieldMap`
216+ parentType . getFields ( ) as GraphQLFieldMap < any , any > ,
217+ ) ;
217218 }
218219
219220 if ( isCompositeType ( parentType ) ) {
@@ -229,7 +230,7 @@ function getSuggestionsForFieldNames(
229230 sortText : String ( index ) + field . name ,
230231 label : field . name ,
231232 detail : String ( field . type ) ,
232- documentation : field . description ,
233+ documentation : field . description ?? undefined ,
233234 deprecated : field . isDeprecated ,
234235 isDeprecated : field . isDeprecated ,
235236 deprecationReason : field . deprecationReason ,
@@ -243,18 +244,18 @@ function getSuggestionsForFieldNames(
243244function getSuggestionsForInputValues (
244245 token : ContextToken ,
245246 typeInfo : AllTypeInfo ,
246- kind : string ,
247+ _kind : string ,
247248) : CompletionItem [ ] {
248249 const namedInputType = getNamedType ( typeInfo . inputType as GraphQLType ) ;
249250 if ( namedInputType instanceof GraphQLEnumType ) {
250- const values : GraphQLEnumValues [ ] = namedInputType . getValues ( ) ;
251+ const values : GraphQLEnumValue [ ] = namedInputType . getValues ( ) ;
251252 return hintList (
252253 token ,
253254 values . map (
254255 ( value : GraphQLEnumValue ) : CompletionItem => ( {
255256 label : value . name ,
256257 detail : String ( namedInputType ) ,
257- documentation : value . description ,
258+ documentation : value . description ?? undefined ,
258259 deprecated : value . isDeprecated ,
259260 isDeprecated : value . isDeprecated ,
260261 deprecationReason : value . deprecationReason ,
@@ -287,7 +288,8 @@ function getSuggestionsForFragmentTypeConditions(
287288 token : ContextToken ,
288289 typeInfo : AllTypeInfo ,
289290 schema : GraphQLSchema ,
290- kind : Kind . TypeCondition | Kind . NamedType ,
291+ // TODO: Kind.TypeCondition | Kind.NamedType,
292+ _kind : string ,
291293) : Array < CompletionItem > {
292294 let possibleTypes : GraphQLType [ ] ;
293295 if ( typeInfo . parentType ) {
@@ -330,7 +332,7 @@ function getSuggestionsForFragmentSpread(
330332 typeInfo : AllTypeInfo ,
331333 schema : GraphQLSchema ,
332334 queryText : string ,
333- kind : string ,
335+ _kind : string ,
334336) : Array < CompletionItem > {
335337 const typeMap = schema . getTypeMap ( ) ;
336338 const defState = getDefinitionState ( token . state ) ;
@@ -407,7 +409,7 @@ export function getFragmentDefinitions(
407409function getSuggestionsForVariableDefinition (
408410 token : ContextToken ,
409411 schema : GraphQLSchema ,
410- kind : string ,
412+ _kind : string ,
411413) : Array < CompletionItem > {
412414 const inputTypeMap = schema . getTypeMap ( ) ;
413415 const inputTypes = objectValues ( inputTypeMap ) . filter ( isInputType ) ;
@@ -426,7 +428,7 @@ function getSuggestionsForDirective(
426428 token : ContextToken ,
427429 state : State ,
428430 schema : GraphQLSchema ,
429- kind : string ,
431+ _kind : string ,
430432) : Array < CompletionItem > {
431433 if ( state . prevState && state . prevState . kind ) {
432434 const directives = schema
0 commit comments