Skip to content

Commit

Permalink
chore: remove @ts-ignore-error (#3629)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasheartman committed Apr 26, 2023
1 parent 2010e5d commit 596d754
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions src/lib/features/export-import-toggles/export-import-service.ts
Expand Up @@ -362,24 +362,23 @@ export default class ExportImportService {
const unsupportedContextFields = await this.getUnsupportedContextFields(
dto,
);
if (
Array.isArray(unsupportedContextFields) &&
unsupportedContextFields.length > 0
) {
throw new UnleashError({
name: 'BadDataError',
message:
'Some of the context fields you are trying to import are not supported.',
// @ts-ignore-error We know that the array contains at least one
// element here.
details: unsupportedContextFields.map((field) => {
if (Array.isArray(unsupportedContextFields)) {
const [firstError, ...remainingErrors] =
unsupportedContextFields.map((field) => {
const description = `${field.name} is not supported.`;
return {
description,
message: description,
};
}),
});
});
if (firstError !== undefined) {
throw new UnleashError({
name: 'BadDataError',
message:
'Some of the context fields you are trying to import are not supported.',
details: [firstError, ...remainingErrors],
});
}
}
}

Expand Down Expand Up @@ -450,21 +449,23 @@ export default class ExportImportService {

private async verifyStrategies(dto: ImportTogglesSchema) {
const unsupportedStrategies = await this.getUnsupportedStrategies(dto);
if (unsupportedStrategies.length > 0) {

const [firstError, ...remainingErrors] = unsupportedStrategies.map(
(strategy) => {
const description = `${strategy.name} is not supported.`;

return {
description,
message: description,
};
},
);
if (firstError !== undefined) {
throw new UnleashError({
name: 'BadDataError',
message:
'Some of the strategies you are trying to import are not supported.',
// @ts-ignore-error We know that the array contains at least one
// element here.
details: unsupportedStrategies.map((strategy) => {
const description = `${strategy.name} is not supported.`;

return {
description,
message: description,
};
}),
details: [firstError, ...remainingErrors],
});
}
}
Expand Down

0 comments on commit 596d754

Please sign in to comment.