Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(ts): enable noImplicitAny on test/request.ts #343

Merged
merged 6 commits into from
Mar 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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