Skip to content

Commit

Permalink
fix(core): Fix TypeScript errors arising in v3.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Jun 6, 2019
1 parent 7eda23b commit 8e78450
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/common/src/simple-deep-clone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* An extremely fast function for deep-cloning an object which only contains simple
* values, i.e. primitives, arrays and nested simple objects.
*/
export function simpleDeepClone<T>(input: T): T {
export function simpleDeepClone<T extends string | number | any[] | object>(input: T): T {
// if not array or object or is null return self
if (typeof input !== 'object' || input === null) {
return input;
Expand All @@ -21,7 +21,7 @@ export function simpleDeepClone<T>(input: T): T {
// handle case: object
output = {};
for (i in input) {
if (input.hasOwnProperty(i)) {
if ((input).hasOwnProperty(i)) {
output[i] = simpleDeepClone((input as any)[i]);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Response } from 'express-serve-static-core';
import { GraphQLError } from 'graphql';
import { GraphQLExtension, GraphQLResponse } from 'graphql-extensions';

import { I18nRequest, I18nService } from '../../i18n/i18n.service';
Expand All @@ -20,7 +21,7 @@ export class TranslateErrorExtension implements GraphQLExtension {
const { graphqlResponse, context } = o;
if (graphqlResponse.errors) {
graphqlResponse.errors = graphqlResponse.errors.map(err => {
return this.i18nService.translateError(context.req, err) as any;
return this.i18nService.translateError(context.req, err as GraphQLError) as any;
});
}
return o;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/common/configurable-operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ export function configurableDefToOperation(def: ConfigurableOperationDef): Confi
* { foo: 'bar' }
**/
export function argsArrayToHash<T>(args: ConfigArg[]): ConfigArgValues<T> {
const output: ConfigArgValues<T> & { [key: string]: any } = {} as any;
const output: ConfigArgValues<T> = {} as any;
for (const arg of args) {
if (arg.value != null) {
output[arg.name] = coerceValueToType<T>(arg);
output[arg.name as keyof ConfigArgValues<T>] = coerceValueToType<T>(arg);
}
}
return output;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function parseFilterParams<T extends VendureEntity>(

for (const [key, operation] of Object.entries(filterParams)) {
if (operation) {
for (const [operator, operand] of Object.entries(operation)) {
for (const [operator, operand] of Object.entries(operation as object)) {
let fieldName: string;
if (columns.find(c => c.propertyName === key)) {
fieldName = `${alias}.${key}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export function parseSortParams<T extends VendureEntity>(

for (const [key, order] of Object.entries(sortParams)) {
if (columns.find(c => c.propertyName === key)) {
output[`${alias}.${key}`] = order;
output[`${alias}.${key}`] = order as any;
} else if (translationColumns.find(c => c.propertyName === key)) {
output[`${alias}_translations.${key}`] = order;
output[`${alias}_translations.${key}`] = order as any;
} else {
throw new UserInputError('error.invalid-sort-field', {
fieldName: key,
Expand Down

0 comments on commit 8e78450

Please sign in to comment.