Skip to content

Commit

Permalink
Use explicit default arguments (#2421)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov authored Feb 3, 2020
1 parent 7335461 commit 468dfb5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/language/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ function addDescription(cb) {
* Given maybeArray, print an empty string if it is null or empty, otherwise
* print all items together separated by separator if provided
*/
function join(maybeArray, separator) {
return maybeArray ? maybeArray.filter(x => x).join(separator || '') : '';
function join(maybeArray: ?Array<string>, separator = '') {
return maybeArray?.filter(x => x).join(separator) || '';
}

/**
Expand All @@ -273,8 +273,8 @@ function block(array) {
* If maybeString is not null or empty, then wrap with start and end, otherwise
* print an empty string.
*/
function wrap(start, maybeString, end) {
return maybeString ? start + maybeString + (end || '') : '';
function wrap(start, maybeString, end = '') {
return maybeString ? start + maybeString + end : '';
}

function indent(maybeString) {
Expand Down
10 changes: 7 additions & 3 deletions src/language/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ export class Source {
name: string;
locationOffset: Location;

constructor(body: string, name?: string, locationOffset?: Location): void {
constructor(
body: string,
name: string = 'GraphQL request',
locationOffset: Location = { line: 1, column: 1 },
): void {
this.body = body;
this.name = name != null ? name : 'GraphQL request';
this.locationOffset = locationOffset || { line: 1, column: 1 };
this.name = name;
this.locationOffset = locationOffset;
devAssert(
this.locationOffset.line > 0,
'line in locationOffset is 1-indexed and must be positive.',
Expand Down

0 comments on commit 468dfb5

Please sign in to comment.