@@ -102,7 +102,7 @@ export interface ParseOptions {
102
102
*/
103
103
export function parse (
104
104
source : string | Source ,
105
- options ?: ParseOptions ,
105
+ options ?: ParseOptions | undefined ,
106
106
) : DocumentNode {
107
107
const parser = new Parser ( source , options ) ;
108
108
return parser . parseDocument ( ) ;
@@ -120,7 +120,7 @@ export function parse(
120
120
*/
121
121
export function parseValue (
122
122
source : string | Source ,
123
- options ?: ParseOptions ,
123
+ options ?: ParseOptions | undefined ,
124
124
) : ValueNode {
125
125
const parser = new Parser ( source , options ) ;
126
126
parser . expectToken ( TokenKind . SOF ) ;
@@ -135,7 +135,7 @@ export function parseValue(
135
135
*/
136
136
export function parseConstValue (
137
137
source : string | Source ,
138
- options ?: ParseOptions ,
138
+ options ?: ParseOptions | undefined ,
139
139
) : ConstValueNode {
140
140
const parser = new Parser ( source , options ) ;
141
141
parser . expectToken ( TokenKind . SOF ) ;
@@ -156,7 +156,7 @@ export function parseConstValue(
156
156
*/
157
157
export function parseType (
158
158
source : string | Source ,
159
- options ?: ParseOptions ,
159
+ options ?: ParseOptions | undefined ,
160
160
) : TypeNode {
161
161
const parser = new Parser ( source , options ) ;
162
162
parser . expectToken ( TokenKind . SOF ) ;
@@ -177,10 +177,10 @@ export function parseType(
177
177
* @internal
178
178
*/
179
179
export class Parser {
180
- protected _options : Maybe < ParseOptions > ;
180
+ protected _options : ParseOptions ;
181
181
protected _lexer : Lexer ;
182
182
183
- constructor ( source : string | Source , options ? : ParseOptions ) {
183
+ constructor ( source : string | Source , options : ParseOptions = { } ) {
184
184
const sourceObj = isSource ( source ) ? source : new Source ( source ) ;
185
185
186
186
this . _lexer = new Lexer ( sourceObj ) ;
@@ -510,7 +510,7 @@ export class Parser {
510
510
// Legacy support for defining variables within fragments changes
511
511
// the grammar of FragmentDefinition:
512
512
// - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet
513
- if ( this . _options ? .allowLegacyFragmentVariables === true ) {
513
+ if ( this . _options . allowLegacyFragmentVariables === true ) {
514
514
return this . node < FragmentDefinitionNode > ( start , {
515
515
kind : Kind . FRAGMENT_DEFINITION ,
516
516
name : this . parseFragmentName ( ) ,
@@ -1387,7 +1387,7 @@ export class Parser {
1387
1387
* given parsed object.
1388
1388
*/
1389
1389
node < T extends { loc ?: Location } > ( startToken : Token , node : T ) : T {
1390
- if ( this . _options ? .noLocation !== true ) {
1390
+ if ( this . _options . noLocation !== true ) {
1391
1391
node . loc = new Location (
1392
1392
startToken ,
1393
1393
this . _lexer . lastToken ,
0 commit comments