Skip to content

Commit 0ed82f5

Browse files
chore: re-enable noImplicitAny (#107)
1 parent f945f72 commit 0ed82f5

31 files changed

+460
-240
lines changed

package-lock.json

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

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,29 @@
6161
"@google-cloud/nodejs-repo-tools": "^2.0.11",
6262
"@types/express": "^4.11.0",
6363
"@types/express-serve-static-core": "^4.11.1",
64+
"@types/extend": "^3.0.0",
6465
"@types/glob": "^5.0.35",
6566
"@types/hapi": "^16.1.11",
6667
"@types/is": "0.0.19",
6768
"@types/koa": "^2.0.43",
69+
"@types/lodash.assign": "^4.2.3",
70+
"@types/lodash.foreach": "^4.5.3",
6871
"@types/lodash.has": "^4.5.3",
72+
"@types/lodash.indexof": "^4.0.3",
73+
"@types/lodash.maxby": "^4.6.3",
74+
"@types/lodash.merge": "^4.6.3",
75+
"@types/lodash.omit": "^4.5.3",
76+
"@types/lodash.omitby": "^4.6.3",
77+
"@types/lodash.pick": "^4.4.3",
78+
"@types/lodash.random": "^3.2.3",
79+
"@types/lodash.without": "^4.4.3",
6980
"@types/mocha": "^5.0.0",
7081
"@types/ncp": "^2.0.1",
82+
"@types/nock": "^9.1.2",
7183
"@types/node": "^9.4.0",
7284
"@types/once": "^1.4.0",
7385
"@types/pify": "^3.0.1",
86+
"@types/proxyquire": "^1.3.28",
7487
"@types/request": "^2.0.9",
7588
"@types/restify": "^5.0.6",
7689
"@types/rimraf": "^2.0.2",

src/classes/error-message.ts

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ export class ErrorMessage {
123123
* error was reported
124124
* @returns {this} - returns the instance for chaining
125125
*/
126-
setServiceContext(service: string, version?: string) {
127-
this.serviceContext.service = isString(service) ? service : 'node';
126+
setServiceContext(service?: string, version?: string) {
127+
this.serviceContext.service = (isString(service) ? service : 'node')!;
128128
this.serviceContext.version = isString(version) ? version : undefined;
129129

130130
return this;
@@ -136,8 +136,8 @@ export class ErrorMessage {
136136
* @param {String} message - the error message
137137
* @returns {this} - returns the instance for chaining
138138
*/
139-
setMessage(message: string) {
140-
this.message = isString(message) ? message : '';
139+
setMessage(message?: string) {
140+
this.message = (isString(message) ? message : '')!;
141141

142142
return this;
143143
}
@@ -149,8 +149,8 @@ export class ErrorMessage {
149149
* errors instantiation
150150
* @returns {this} - returns the instance for chaining
151151
*/
152-
setHttpMethod(method: string) {
153-
this.context.httpRequest.method = isString(method) ? method : '';
152+
setHttpMethod(method?: string) {
153+
this.context.httpRequest.method = (isString(method) ? method : '')!;
154154

155155
return this;
156156
}
@@ -161,8 +161,8 @@ export class ErrorMessage {
161161
* @param {String} url - the requests target url
162162
* @returns {this} - returns the instance for chaining
163163
*/
164-
setUrl(url: string) {
165-
this.context.httpRequest.url = isString(url) ? url : '';
164+
setUrl(url?: string) {
165+
this.context.httpRequest.url = (isString(url) ? url : '')!;
166166

167167
return this;
168168
}
@@ -173,8 +173,9 @@ export class ErrorMessage {
173173
* @param {String} userAgent - the requests user-agent
174174
* @returns {this} - returns the instance for chaining
175175
*/
176-
setUserAgent(userAgent: string) {
177-
this.context.httpRequest.userAgent = isString(userAgent) ? userAgent : '';
176+
setUserAgent(userAgent?: string) {
177+
this.context.httpRequest.userAgent =
178+
(isString(userAgent) ? userAgent : '')!;
178179

179180
return this;
180181
}
@@ -185,8 +186,8 @@ export class ErrorMessage {
185186
* @param {String} referrer - the requests referrer
186187
* @returns {this} - returns the instance for chaining
187188
*/
188-
setReferrer(referrer: string) {
189-
this.context.httpRequest.referrer = isString(referrer) ? referrer : '';
189+
setReferrer(referrer?: string) {
190+
this.context.httpRequest.referrer = (isString(referrer) ? referrer : '')!;
190191

191192
return this;
192193
}
@@ -197,9 +198,9 @@ export class ErrorMessage {
197198
* @param {Number} responseStatusCode - the response status code
198199
* @returns {this} - returns the instance for chaining
199200
*/
200-
setResponseStatusCode(responseStatusCode: number) {
201+
setResponseStatusCode(responseStatusCode?: number) {
201202
this.context.httpRequest.responseStatusCode =
202-
isNumber(responseStatusCode) ? responseStatusCode : 0;
203+
(isNumber(responseStatusCode) ? responseStatusCode : 0)!;
203204

204205
return this;
205206
}
@@ -210,8 +211,8 @@ export class ErrorMessage {
210211
* @param {String} remoteIp - the requesters remote IP
211212
* @returns {this} - returns the instance for chaining
212213
*/
213-
setRemoteIp(remoteIp: string) {
214-
this.context.httpRequest.remoteIp = isString(remoteIp) ? remoteIp : '';
214+
setRemoteIp(remoteIp?: string) {
215+
this.context.httpRequest.remoteIp = (isString(remoteIp) ? remoteIp : '')!;
215216

216217
return this;
217218
}
@@ -222,8 +223,8 @@ export class ErrorMessage {
222223
* @param {String} user - the vm instances user
223224
* @returns {this} - returns the instance for chaining
224225
*/
225-
setUser(user: string) {
226-
this.context.user = isString(user) ? user : '';
226+
setUser(user?: string) {
227+
this.context.user = (isString(user) ? user : '')!;
227228

228229
return this;
229230
}
@@ -234,8 +235,9 @@ export class ErrorMessage {
234235
* @param {String} filePath - the vm instances filePath
235236
* @returns {this} - returns the instance for chaining
236237
*/
237-
setFilePath(filePath: string) {
238-
this.context.reportLocation.filePath = isString(filePath) ? filePath : '';
238+
setFilePath(filePath?: string) {
239+
this.context.reportLocation.filePath =
240+
(isString(filePath) ? filePath : '')!;
239241

240242
return this;
241243
}
@@ -246,9 +248,9 @@ export class ErrorMessage {
246248
* @param {Number} lineNumber - the line number of the report context
247249
* @returns {this} - returns the instance for chaining
248250
*/
249-
setLineNumber(lineNumber: number) {
251+
setLineNumber(lineNumber?: number) {
250252
this.context.reportLocation.lineNumber =
251-
isNumber(lineNumber) ? lineNumber : 0;
253+
(isNumber(lineNumber) ? lineNumber : 0)!;
252254

253255
return this;
254256
}
@@ -259,9 +261,9 @@ export class ErrorMessage {
259261
* @param {String} functionName - the function name of the report context
260262
* @returns {this} - returns the instance for chaining
261263
*/
262-
setFunctionName(functionName: string) {
264+
setFunctionName(functionName?: string) {
263265
this.context.reportLocation.functionName =
264-
isString(functionName) ? functionName : '';
266+
(isString(functionName) ? functionName : '')!;
265267

266268
return this;
267269
}

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ export class ErrorReporting {
9999
private _logger: types.Logger;
100100
private _config: Configuration;
101101
private _client: AuthClient;
102+
// the `err` argument can be anything, including `null` and `undefined`
102103
report:
103-
(err: {}, request?: manualRequestExtractor.Request,
104-
additionalMessage?: string|{},
104+
(err: any, // tslint:disable-line:no-any
105+
request?: manualRequestExtractor.Request, additionalMessage?: string|{},
105106
callback?: manualInterface.Callback|{}|string) => ErrorMessage;
106107
event: () => ErrorMessage;
107108
hapi: {register: (server: {}, options: {}, next: Function) => void};

src/interfaces/manual.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ export function handlerSetup(
6464
* @returns {ErrorMessage} - returns the error message created through with
6565
* the parameters given.
6666
*/
67+
// the `err` argument can be anything, including `null` and `undefined`
6768
function reportManualError(
68-
err: {}, request?: Request|Callback|string,
69-
additionalMessage?: Callback|string|{}, callback?: Callback|{}|string) {
69+
err: any, // tslint:disable-line:no-any
70+
request?: Request|Callback|string, additionalMessage?: Callback|string|{},
71+
callback?: Callback|{}|string) {
7072
let em;
7173
if (isString(request)) {
7274
// no request given

src/logger.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717

1818
import has = require('lodash.has');
1919
import * as is from 'is';
20+
import * as types from './types';
21+
2022
const isObject = is.object;
2123
const isString = is.string;
2224
const isNumber = is.number;
23-
import {logger} from '@google-cloud/common';
25+
const logger: types.logger = require('@google-cloud/common').logger;
26+
2427
const packageJson = require('../../package.json');
2528

2629
import {ConfigurationOptions} from './configuration';

src/populate-error-message.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ export interface PopulatedObject {
4040
* information into
4141
* @returns {Undefined} - does not return a value
4242
*/
43-
export function populateErrorMessage(ob: {}, em: ErrorMessage) {
43+
// the `ob` argument can be anything, including `null` and `undefined`
44+
// tslint:disable-next-line:no-any
45+
export function populateErrorMessage(ob: any, em: ErrorMessage) {
4446
if (ob === null || ob === undefined) {
4547
em.setMessage(buildStackTrace('' + ob));
4648
} else if ((ob as {stack: {}}).stack) {

src/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export interface LoggerOptions {
3939

4040
export interface logger {
4141
(options?: LoggerOptions | string): Logger;
42-
LEVELS: string[];
42+
LEVELS: string[] & { [key: string]: string; };
4343
}
4444

4545
export interface Options {

0 commit comments

Comments
 (0)