Skip to content

Commit

Permalink
refactor(ts): enable noImplicitAny on test/request.ts (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Cervino authored and JustinBeckwith committed Mar 6, 2019
1 parent 165e492 commit 5bb02b8
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 150 deletions.
41 changes: 18 additions & 23 deletions src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,7 @@ class DatastoreRequest {
callback: GetCallback): void;
get(keys: Entities, optionsOrCallback?: CreateReadStreamOptions|GetCallback,
cb?: GetCallback): void|Promise<Entity|Transform> {
const options =
typeof optionsOrCallback === 'object' && optionsOrCallback !== null ?
const options = typeof optionsOrCallback === 'object' && optionsOrCallback ?
optionsOrCallback :
{};
const callback =
Expand Down Expand Up @@ -667,8 +666,7 @@ class DatastoreRequest {
query = extend(true, new Query(), query);

const makeRequest = (query: Query) => {
// tslint:disable-next-line no-any
const reqOpts: any = {
const reqOpts: Any = {
query: entity.queryToQueryProto(query),
};

Expand Down Expand Up @@ -701,17 +699,15 @@ class DatastoreRequest {
return;
}

// tslint:disable-next-line no-any
const info: any = {
const info: Any = {
moreResults: resp.batch.moreResults,
};

if (resp.batch.endCursor) {
info.endCursor = resp.batch.endCursor.toString('base64');
}

// tslint:disable-next-line no-any
let entities: any[] = [];
let entities: Any[] = [];

if (resp.batch.entityResults) {
entities = entity.formatArray(resp.batch.entityResults);
Expand Down Expand Up @@ -1050,17 +1046,16 @@ class DatastoreRequest {
return;
}

arrify(resp.mutationResults)
.forEach((result: Entity, index: number) => { //! Entity malo
if (!result.key) {
return;
}
arrify(resp.mutationResults).forEach((result, index) => {
if (!result.key) {
return;
}

if (insertIndexes[index]) {
const id = entity.keyFromKeyProto(result.key).id;
entities[index].key.id = id;
}
});
if (insertIndexes[index]) {
const id = entity.keyFromKeyProto(result.key).id;
entities[index].key.id = id;
}
});

callback(null, resp);
}
Expand Down Expand Up @@ -1208,6 +1203,8 @@ class DatastoreRequest {
}
}

// tslint:disable-next-line no-any
type Any = any;
export interface BooleanObject {
[key: string]: boolean;
}
Expand Down Expand Up @@ -1253,8 +1250,7 @@ export interface Mutation extends google.datastore.v1.IMutation {
[key: string]: Entity;
}
export interface PrepareEntityObject {
[key: string]: google.datastore.v1.Key|
undefined; // TODO: Fix "Symbol cannot be key" TS error
[key: string]: google.datastore.v1.Key|undefined;
}
export interface PrepareEntityObjectResponse {
key?: google.datastore.v1.Key;
Expand All @@ -1269,10 +1265,10 @@ export interface RequestCallback {
}
export interface RequestConfig {
client: string;
gaxOpts?: number|CallOptions|KeyProto|undefined;
gaxOpts?: number|CallOptions|KeyProto;
method: string;
prepared?: boolean;
reqOpts?: RequestOptions;
reqOpts?: Entity|RequestOptions;
}
export interface RequestOptions {
mutations?: []|Array<{delete: KeyProto;}>|Array<{}>;
Expand All @@ -1284,7 +1280,6 @@ export interface RequestOptions {
mode?: string;
projectId?: string;
}
export interface RequestResponse extends google.datastore.v1.ICommitResponse {}
export interface RunQueryStreamOptions {
gaxOptions?: CallOptions;
consistency?: 'strong'|'eventual';
Expand Down

0 comments on commit 5bb02b8

Please sign in to comment.