Skip to content

Commit 42cbaa1

Browse files
committed
build: use target es2016 for typescript
BREAKING CHANGE: minimal supported NodeJS version is 7.5.0
1 parent 99edddb commit 42cbaa1

File tree

6 files changed

+38
-24
lines changed

6 files changed

+38
-24
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"eslint": "7.0.0",
3838
"eslint-config-airbnb-base": "14.1.0",
3939
"eslint-config-prettier": "6.11.0",
40-
"eslint-plugin-flowtype": "5.1.0",
4140
"eslint-plugin-import": "2.20.2",
4241
"eslint-plugin-prettier": "3.1.3",
4342
"express": "^4.17.1",
@@ -50,7 +49,7 @@
5049
"rimraf": "3.0.2",
5150
"semantic-release": "17.0.7",
5251
"ts-jest": "26.0.0",
53-
"ts-node": "8.10.1",
52+
"c": "8.10.1",
5453
"typescript": "3.9.2"
5554
},
5655
"scripts": {

src/__fixtures__/Film.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fetch from 'node-fetch';
22
import { composeWithJson } from '../index';
33
import { PeopleTC } from './People';
4+
import { ResolverResolveParams } from 'graphql-compose';
45

56
const restApiResponse = {
67
title: 'The Empire Strikes Back',
@@ -28,7 +29,7 @@ FilmTC.addResolver({
2829
args: {
2930
id: 'Int!',
3031
},
31-
resolve: (rp) => {
32+
resolve: (rp: ResolverResolveParams<any, any>) => {
3233
return fetch(`https://swapi.co/api/films/${rp.args.id}/`).then((r) => r.json());
3334
},
3435
});
@@ -39,7 +40,7 @@ FilmTC.addResolver({
3940
args: {
4041
url: 'String!',
4142
},
42-
resolve: (rp) => fetch(rp.args.url).then((r) => r.json()),
43+
resolve: (rp: ResolverResolveParams<any, any>) => fetch(rp.args.url).then((r) => r.json()),
4344
});
4445

4546
FilmTC.addResolver({
@@ -48,8 +49,8 @@ FilmTC.addResolver({
4849
args: {
4950
urls: '[String]!',
5051
},
51-
resolve: (rp) => {
52-
return Promise.all(rp.args.urls.map((url) => fetch(url).then((r) => r.json())));
52+
resolve: (rp: ResolverResolveParams<any, any>) => {
53+
return Promise.all(rp.args.urls.map((url: string) => fetch(url).then((r) => r.json())));
5354
},
5455
});
5556

src/__fixtures__/People.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fetch from 'node-fetch';
22
import { composeWithJson } from '../index';
33
import { FilmTC } from './Film';
4+
import { ResolverResolveParams } from 'graphql-compose';
45

56
const restApiResponse = {
67
name: 'Luke Skywalker',
@@ -30,7 +31,7 @@ PeopleTC.addResolver({
3031
args: {
3132
id: 'Int!',
3233
},
33-
resolve: (rp) => {
34+
resolve: (rp: ResolverResolveParams<any, any>) => {
3435
return fetch(`https://swapi.co/api/people/${rp.args.id}/`).then((r) => r.json());
3536
},
3637
});
@@ -41,7 +42,7 @@ PeopleTC.addResolver({
4142
args: {
4243
url: 'String!',
4344
},
44-
resolve: (rp) => fetch(rp.args.url).then((r) => r.json()),
45+
resolve: (rp: ResolverResolveParams<any, any>) => fetch(rp.args.url).then((r) => r.json()),
4546
});
4647

4748
PeopleTC.addResolver({
@@ -50,8 +51,8 @@ PeopleTC.addResolver({
5051
args: {
5152
urls: '[String]!',
5253
},
53-
resolve: (rp) => {
54-
return Promise.all(rp.args.urls.map((url) => fetch(url).then((r) => r.json())));
54+
resolve: (rp: ResolverResolveParams<any, any>) => {
55+
return Promise.all(rp.args.urls.map((url: string) => fetch(url).then((r) => r.json())));
5556
},
5657
});
5758

src/__tests__/composeWithJson-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe.skip('composeWithJson', () => {
7676
// ],
7777
planets: () => ({
7878
type: 'Int',
79-
resolve: (source) => source.planets.length,
79+
resolve: (source: any) => source.planets.length,
8080
}),
8181
// characters: [
8282
// 'https://swapi.co/api/people/1/',

tsconfig.build.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
4-
"types": ["node", "jest"]
4+
"types": ["node"],
5+
"outDir": "./lib",
56
},
67
"include": ["src/**/*"],
7-
"exclude": ["**/__tests__"]
8-
}
8+
"exclude": ["**/__tests__", "**/__mocks__"]
9+
}

tsconfig.json

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
{
22
"compilerOptions": {
3-
"target": "es5",
3+
"target": "es2016",
44
"module": "commonjs",
5-
"strict": true,
6-
"declaration": true,
7-
"declarationMap": true,
8-
"rootDir": "./src",
9-
"outDir": "./lib",
10-
"lib": ["es2017"],
115
"moduleResolution": "node",
126
"esModuleInterop": true,
7+
"sourceMap": true,
8+
"declaration": true,
9+
"declarationMap": true,
10+
"removeComments": true,
11+
"strict": true,
12+
"noImplicitAny": true,
13+
"noImplicitReturns": true,
14+
"noFallthroughCasesInSwitch": true,
15+
"noUnusedParameters": true,
16+
"noUnusedLocals": true,
1317
"forceConsistentCasingInFileNames": true,
14-
"noImplicitAny": false,
15-
"types": ["node", "jest"]
18+
"lib": ["es2017", "esnext.asynciterable"],
19+
"types": ["node", "jest"],
20+
"baseUrl": ".",
21+
"paths": {
22+
"*" : ["types/*"]
23+
},
24+
"rootDir": "./src",
1625
},
17-
"include": ["src/**/*.ts", "*.js"]
26+
"include": ["src/**/*"],
27+
"exclude": [
28+
"./node_modules"
29+
]
1830
}

0 commit comments

Comments
 (0)