Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit bc78694

Browse files
committed
Add missing parameter types
1 parent 3c26db7 commit bc78694

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

src/__tests__/http-test.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
GraphQLNonNull,
2020
GraphQLString,
2121
GraphQLError,
22+
ValidationContext,
2223
BREAK,
2324
Source,
2425
validate,
@@ -75,11 +76,13 @@ function urlString(urlParams?: { [param: string]: string, ... }): string {
7576
return string;
7677
}
7778

78-
[
79+
const implementations: Array<[(...args: Array<any>) => any, string]> = [
7980
[connect, 'connect'],
8081
[express, 'express'],
8182
[restify.createServer, 'restify'],
82-
].forEach(([serverImpl, name]) => {
83+
];
84+
85+
implementations.forEach(([serverImpl, name]) => {
8386
function server() {
8487
const app = serverImpl();
8588
if (app.set) {
@@ -94,12 +97,12 @@ function urlString(urlParams?: { [param: string]: string, ... }): string {
9497
return app;
9598
}
9699

97-
function get(app, ...args) {
100+
function get(app: any, ...args: Array<any>) {
98101
// Connect only likes using app.use.
99102
return app.get ? app.get(...args) : app.use(...args);
100103
}
101104

102-
function post(app, ...args) {
105+
function post(app: any, ...args: Array<any>) {
103106
// Connect only likes using app.use.
104107
return app.post ? app.post(...args) : app.use(...args);
105108
}
@@ -2016,7 +2019,7 @@ function urlString(urlParams?: { [param: string]: string, ... }): string {
20162019
});
20172020

20182021
describe('Custom validation rules', () => {
2019-
const AlwaysInvalidRule = function (context) {
2022+
const AlwaysInvalidRule = function (context: ValidationContext) {
20202023
return {
20212024
enter() {
20222025
context.reportError(

src/parseBody.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ export async function parseBody(
7676
const jsonObjRegex = /^[ \t\n\r]*\{/;
7777

7878
// Read and parse a request body.
79-
async function readBody(req, typeInfo) {
79+
async function readBody(
80+
req: $Request,
81+
typeInfo: {| type: string, parameters: { [param: string]: string, ... } |},
82+
) {
8083
const charset = (typeInfo.parameters.charset ?? 'utf-8').toLowerCase();
8184

8285
// Assert charset encoding per JSON RFC 7159 sec 8.1
@@ -105,7 +108,7 @@ async function readBody(req, typeInfo) {
105108
}
106109

107110
// Return a decompressed stream, given an encoding.
108-
function decompressed(req, encoding) {
111+
function decompressed(req: $Request, encoding: string) {
109112
switch (encoding) {
110113
case 'identity':
111114
return req;

src/renderGraphiQL.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ export type GraphiQLOptions = {|
1919
|};
2020

2121
// Ensures string values are safe to be used within a <script> tag.
22-
function safeSerialize(data) {
22+
function safeSerialize(data: mixed) {
2323
return data != null
24-
? JSON.stringify(data).replace(/\//g, '\\/')
24+
? ((JSON.stringify(data): any): string).replace(/\//g, '\\/')
2525
: 'undefined';
2626
}
2727

0 commit comments

Comments
 (0)