@@ -164,7 +164,7 @@ export function parseType(
164
164
}
165
165
166
166
class Parser {
167
- _options : ParseOptions ;
167
+ _options : ? ParseOptions ;
168
168
_lexer : Lexer ;
169
169
170
170
constructor ( source : string | Source , options ?: ParseOptions ) {
@@ -175,12 +175,7 @@ class Parser {
175
175
) ;
176
176
177
177
this . _lexer = new Lexer ( sourceObj ) ;
178
- this . _options = options || {
179
- noLocation : false ,
180
- allowLegacySDLEmptyFields : false ,
181
- allowLegacySDLImplementsInterfaces : false ,
182
- experimentalFragmentVariables : false ,
183
- } ;
178
+ this . _options = options ;
184
179
}
185
180
186
181
/**
@@ -483,7 +478,7 @@ class Parser {
483
478
// Experimental support for defining variables within fragments changes
484
479
// the grammar of FragmentDefinition:
485
480
// - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet
486
- if ( this . _options . experimentalFragmentVariables ) {
481
+ if ( this . _options ? .experimentalFragmentVariables === true ) {
487
482
return {
488
483
kind : Kind . FRAGMENT_DEFINITION ,
489
484
name : this . parseFragmentName ( ) ,
@@ -869,7 +864,7 @@ class Parser {
869
864
} while (
870
865
this . expectOptionalToken ( TokenKind . AMP ) ||
871
866
// Legacy support for the SDL?
872
- ( this . _options . allowLegacySDLImplementsInterfaces &&
867
+ ( this . _options ? .allowLegacySDLImplementsInterfaces === true &&
873
868
this . peek ( TokenKind . NAME ) )
874
869
) ;
875
870
}
@@ -882,7 +877,7 @@ class Parser {
882
877
parseFieldsDefinition ( ) : Array < FieldDefinitionNode > {
883
878
// Legacy support for the SDL?
884
879
if (
885
- this . _options . allowLegacySDLEmptyFields &&
880
+ this . _options ? .allowLegacySDLEmptyFields === true &&
886
881
this . peek ( TokenKind . BRACE_L ) &&
887
882
this . _lexer . lookahead ( ) . kind === TokenKind . BRACE_R
888
883
) {
@@ -1403,7 +1398,7 @@ class Parser {
1403
1398
* the source that created a given parsed object.
1404
1399
*/
1405
1400
loc ( startToken : Token ) : Location | void {
1406
- if ( ! this . _options . noLocation ) {
1401
+ if ( this . _options ? .noLocation !== true ) {
1407
1402
return new Location (
1408
1403
startToken ,
1409
1404
this . _lexer . lastToken ,
0 commit comments