1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-05-08 01:15:49 +02:00

chore: remove @ts-ignore-error (#3629)

This commit is contained in:
Thomas Heartman 2023-04-26 17:08:55 +02:00 committed by GitHub
parent 2010e5d345
commit 596d7543e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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],
});
}
}
}
@ -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],
});
}
}