Skip to content

Commit 91cd8e5

Browse files
committed
Update to TypeScript 3.7
1 parent 50ecfae commit 91cd8e5

File tree

7 files changed

+1293
-19
lines changed

7 files changed

+1293
-19
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ lib
33
*.lock
44
*.log
55
*.tgz
6-
package-lock.json
76
.idea/

.npmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
package-lock=false
1+
save-exact=True

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@
3737
## 1.2.0
3838

3939
* Added Enum support, thanks @douglaseggleton
40+
41+
## 2.0.0
42+
43+
* Update to TypeScript 3.7

package-lock.json

Lines changed: 1270 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-to-graphql-query",
3-
"version": "1.9.0",
3+
"version": "2.0.0",
44
"main": "lib/index.js",
55
"license": "MIT",
66
"scripts": {
@@ -15,13 +15,13 @@
1515
"url": "https://github.com/dupski/json-to-graphql-query.git"
1616
},
1717
"devDependencies": {
18-
"@types/chai": "^4.0.10",
19-
"@types/mocha": "^2.2.45",
20-
"chai": "^4.1.2",
21-
"mocha": "^4.1.0",
22-
"sinon": "^4.1.3",
23-
"ts-node": "^4.1.0",
24-
"tslint": "5.8.0",
25-
"typescript": "2.6.2"
18+
"@types/chai": "4.2.8",
19+
"@types/mocha": "7.0.1",
20+
"chai": "4.2.0",
21+
"mocha": "7.0.1",
22+
"sinon": "8.1.1",
23+
"ts-node": "8.6.2",
24+
"tslint": "6.0.0",
25+
"typescript": "3.7.5"
2626
}
2727
}

src/jsonToGraphQLQuery.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ function filterNonConfigFields(fieldName: string, ignoreFields: string[]) {
7676
return configFields.indexOf(fieldName) == -1 && ignoreFields.indexOf(fieldName) == -1;
7777
}
7878

79-
function convertQuery(node: any, level: number, output: Array<[string, number]>, options: IJsonToGraphQLOptions) {
79+
function convertQuery(node: any, level: number, output: [string, number][], options: IJsonToGraphQLOptions) {
8080
Object.keys(node)
81-
.filter((key) => filterNonConfigFields(key, options.ignoreFields))
81+
.filter((key) => filterNonConfigFields(key, options.ignoreFields!))
8282
.forEach((key) => {
8383
let value = node[key];
8484
if (typeof value === 'object') {
@@ -91,7 +91,7 @@ function convertQuery(node: any, level: number, output: Array<[string, number]>,
9191
}
9292

9393
const fieldCount = Object.keys(value)
94-
.filter((keyCount) => filterNonConfigFields(keyCount, options.ignoreFields)).length;
94+
.filter((keyCount) => filterNonConfigFields(keyCount, options.ignoreFields!)).length;
9595
const subFields = fieldCount > 0;
9696
const argsExist = typeof value.__args === 'object';
9797
const directivesExist = typeof value.__directives === 'object';
@@ -107,8 +107,8 @@ function convertQuery(node: any, level: number, output: Array<[string, number]>,
107107
token = `${token} (${buildVariables(value.__variables)})`;
108108
}
109109
else if (argsExist || directivesExist) {
110-
let argsStr: string;
111-
let dirsStr: string;
110+
let argsStr = '';
111+
let dirsStr = '';
112112
if (directivesExist) {
113113
// TODO: Add support for multiple directives on one node.
114114
const numDirectives = Object.keys(value.__directives).length;
@@ -123,7 +123,7 @@ function convertQuery(node: any, level: number, output: Array<[string, number]>,
123123
argsStr = `(${buildArgs(value.__args)})`;
124124
}
125125
const spacer = directivesExist && argsExist ? ' ' : '';
126-
token = `${token} ${dirsStr ? dirsStr : ''}${spacer}${argsStr ? argsStr : ''}`;
126+
token = `${token} ${dirsStr}${spacer}${argsStr}`;
127127
}
128128

129129
// DEPRECATED: Should be removed in version 2.0.0
@@ -135,7 +135,7 @@ function convertQuery(node: any, level: number, output: Array<[string, number]>,
135135
convertQuery(value, level + 1, output, options);
136136

137137
if (inlineFragmentsExist) {
138-
const inlineFragments: Array<{ __typeName: string }>
138+
const inlineFragments: { __typeName: string }[]
139139
= value.__on instanceof Array ? value.__on : [value.__on];
140140
inlineFragments.forEach((inlineFragment) => {
141141
const name = inlineFragment.__typeName;
@@ -172,7 +172,7 @@ export function jsonToGraphQLQuery(query: any, options: IJsonToGraphQLOptions =
172172
options.ignoreFields = [];
173173
}
174174

175-
const queryLines: Array<[string, number]> = [];
175+
const queryLines: [string, number][] = [];
176176
convertQuery(query, 0, queryLines, options);
177177

178178
let output = '';

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"experimentalDecorators": true,
1010
"removeComments": true,
1111
"noUnusedLocals": true,
12+
"strict": true,
1213
"lib": [
1314
"es2015"
1415
]

0 commit comments

Comments
 (0)