From e80e3a8056fec8003fa68c7807945909dfbfe269 Mon Sep 17 00:00:00 2001
From: SharglutDev
Date: Mon, 16 Dec 2024 09:45:32 +0100
Subject: [PATCH] front: update typescript-eslint
- Remove the ban-types related to React.FC in .eslintrc as ban-types is
not supported anymore and as we don't use RC in the appr anymore anyway.
- Remove some unneeded asserts
- Error in a catch now need to be handled, use the error in setFailure
to display notifications to the user
Signed-off-by: SharglutDev
---
front/.eslintrc | 2 +-
front/package-lock.json | 185 +++++++++---------
front/package.json | 4 +-
.../editor/components/EntitySumUp.tsx | 22 ++-
.../LinearMetadata/FormComponent.tsx | 2 +
.../components/RouteEditionLeftPanel.tsx | 1 +
.../editor/tools/selection/tool.tsx | 6 +-
.../editor/tools/switchEdition/utils.ts | 4 +-
.../views/RollingStockEditor.tsx | 2 +-
front/src/common/Map/Layers/blankStyle.ts | 1 +
.../Map/Search/useSearchOperationalPoint.tsx | 3 +
front/src/common/api/graouApi.ts | 6 +-
.../InfraSelectorModalBodyEdition.tsx | 1 +
.../TrainHoverPosition.tsx | 2 +-
.../ImportTrainScheduleConfig.tsx | 2 +-
.../ImportTrainScheduleTrainsList.tsx | 2 +-
front/src/reducers/mapViewer/index.ts | 2 +-
17 files changed, 129 insertions(+), 118 deletions(-)
diff --git a/front/.eslintrc b/front/.eslintrc
index 13df1c51db7..a8d736ad852 100644
--- a/front/.eslintrc
+++ b/front/.eslintrc
@@ -48,7 +48,7 @@
"@typescript-eslint/no-unsafe-call": "error",
"@typescript-eslint/non-nullable-type-assertion-style": "error",
- "@typescript-eslint/ban-types": [
+ "@typescript-eslint/no-restricted-types": [
"error",
{
"types": {
diff --git a/front/package-lock.json b/front/package-lock.json
index e9e8071400c..15c25a916c1 100644
--- a/front/package-lock.json
+++ b/front/package-lock.json
@@ -124,8 +124,8 @@
"@types/react-transition-group": "^4.4.12",
"@types/tether": "^1.4.9",
"@types/uuid": "^10.0.0",
- "@typescript-eslint/eslint-plugin": "^6.20.0",
- "@typescript-eslint/parser": "^6.20.0",
+ "@typescript-eslint/eslint-plugin": "^8.19.0",
+ "@typescript-eslint/parser": "^8.19.0",
"@vitejs/plugin-react": "^4.3.4",
"@vitejs/plugin-react-swc": "^3.7.2",
"@vitest/coverage-v8": "^2.1.8",
@@ -4679,82 +4679,72 @@
"license": "MIT"
},
"node_modules/@typescript-eslint/eslint-plugin": {
- "version": "6.21.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.21.0.tgz",
- "integrity": "sha512-oy9+hTPCUFpngkEZUSzbf9MxI65wbKFoQYsgPdILTfbUldp5ovUuphZVe4i30emU9M/kP+T64Di0mxl7dSw3MA==",
+ "version": "8.19.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.19.0.tgz",
+ "integrity": "sha512-NggSaEZCdSrFddbctrVjkVZvFC6KGfKfNK0CU7mNK/iKHGKbzT4Wmgm08dKpcZECBu9f5FypndoMyRHkdqfT1Q==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@eslint-community/regexpp": "^4.5.1",
- "@typescript-eslint/scope-manager": "6.21.0",
- "@typescript-eslint/type-utils": "6.21.0",
- "@typescript-eslint/utils": "6.21.0",
- "@typescript-eslint/visitor-keys": "6.21.0",
- "debug": "^4.3.4",
+ "@eslint-community/regexpp": "^4.10.0",
+ "@typescript-eslint/scope-manager": "8.19.0",
+ "@typescript-eslint/type-utils": "8.19.0",
+ "@typescript-eslint/utils": "8.19.0",
+ "@typescript-eslint/visitor-keys": "8.19.0",
"graphemer": "^1.4.0",
- "ignore": "^5.2.4",
+ "ignore": "^5.3.1",
"natural-compare": "^1.4.0",
- "semver": "^7.5.4",
- "ts-api-utils": "^1.0.1"
+ "ts-api-utils": "^1.3.0"
},
"engines": {
- "node": "^16.0.0 || >=18.0.0"
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
- "@typescript-eslint/parser": "^6.0.0 || ^6.0.0-alpha",
- "eslint": "^7.0.0 || ^8.0.0"
- },
- "peerDependenciesMeta": {
- "typescript": {
- "optional": true
- }
+ "@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0",
+ "eslint": "^8.57.0 || ^9.0.0",
+ "typescript": ">=4.8.4 <5.8.0"
}
},
"node_modules/@typescript-eslint/parser": {
- "version": "6.21.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.21.0.tgz",
- "integrity": "sha512-tbsV1jPne5CkFQCgPBcDOt30ItF7aJoZL997JSF7MhGQqOeT3svWRYxiqlfA5RUdlHN6Fi+EI9bxqbdyAUZjYQ==",
+ "version": "8.19.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.19.0.tgz",
+ "integrity": "sha512-6M8taKyOETY1TKHp0x8ndycipTVgmp4xtg5QpEZzXxDhNvvHOJi5rLRkLr8SK3jTgD5l4fTlvBiRdfsuWydxBw==",
"dev": true,
- "license": "BSD-2-Clause",
+ "license": "MIT",
"dependencies": {
- "@typescript-eslint/scope-manager": "6.21.0",
- "@typescript-eslint/types": "6.21.0",
- "@typescript-eslint/typescript-estree": "6.21.0",
- "@typescript-eslint/visitor-keys": "6.21.0",
+ "@typescript-eslint/scope-manager": "8.19.0",
+ "@typescript-eslint/types": "8.19.0",
+ "@typescript-eslint/typescript-estree": "8.19.0",
+ "@typescript-eslint/visitor-keys": "8.19.0",
"debug": "^4.3.4"
},
"engines": {
- "node": "^16.0.0 || >=18.0.0"
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
- "eslint": "^7.0.0 || ^8.0.0"
- },
- "peerDependenciesMeta": {
- "typescript": {
- "optional": true
- }
+ "eslint": "^8.57.0 || ^9.0.0",
+ "typescript": ">=4.8.4 <5.8.0"
}
},
"node_modules/@typescript-eslint/scope-manager": {
- "version": "6.21.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.21.0.tgz",
- "integrity": "sha512-OwLUIWZJry80O99zvqXVEioyniJMa+d2GrqpUTqi5/v5D5rOrppJVBPa0yKCblcigC0/aYAzxxqQ1B+DS2RYsg==",
+ "version": "8.19.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.19.0.tgz",
+ "integrity": "sha512-hkoJiKQS3GQ13TSMEiuNmSCvhz7ujyqD1x3ShbaETATHrck+9RaDdUbt+osXaUuns9OFwrDTTrjtwsU8gJyyRA==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@typescript-eslint/types": "6.21.0",
- "@typescript-eslint/visitor-keys": "6.21.0"
+ "@typescript-eslint/types": "8.19.0",
+ "@typescript-eslint/visitor-keys": "8.19.0"
},
"engines": {
- "node": "^16.0.0 || >=18.0.0"
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
@@ -4762,41 +4752,37 @@
}
},
"node_modules/@typescript-eslint/type-utils": {
- "version": "6.21.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.21.0.tgz",
- "integrity": "sha512-rZQI7wHfao8qMX3Rd3xqeYSMCL3SoiSQLBATSiVKARdFGCYSRvmViieZjqc58jKgs8Y8i9YvVVhRbHSTA4VBag==",
+ "version": "8.19.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.19.0.tgz",
+ "integrity": "sha512-TZs0I0OSbd5Aza4qAMpp1cdCYVnER94IziudE3JU328YUHgWu9gwiwhag+fuLeJ2LkWLXI+F/182TbG+JaBdTg==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@typescript-eslint/typescript-estree": "6.21.0",
- "@typescript-eslint/utils": "6.21.0",
+ "@typescript-eslint/typescript-estree": "8.19.0",
+ "@typescript-eslint/utils": "8.19.0",
"debug": "^4.3.4",
- "ts-api-utils": "^1.0.1"
+ "ts-api-utils": "^1.3.0"
},
"engines": {
- "node": "^16.0.0 || >=18.0.0"
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
- "eslint": "^7.0.0 || ^8.0.0"
- },
- "peerDependenciesMeta": {
- "typescript": {
- "optional": true
- }
+ "eslint": "^8.57.0 || ^9.0.0",
+ "typescript": ">=4.8.4 <5.8.0"
}
},
"node_modules/@typescript-eslint/types": {
- "version": "6.21.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.21.0.tgz",
- "integrity": "sha512-1kFmZ1rOm5epu9NZEZm1kckCDGj5UJEf7P1kliH4LKu/RkwpsfqqGmY2OOcUs18lSlQBKLDYBOGxRVtrMN5lpg==",
+ "version": "8.19.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.19.0.tgz",
+ "integrity": "sha512-8XQ4Ss7G9WX8oaYvD4OOLCjIQYgRQxO+qCiR2V2s2GxI9AUpo7riNwo6jDhKtTcaJjT8PY54j2Yb33kWtSJsmA==",
"dev": true,
"license": "MIT",
"engines": {
- "node": "^16.0.0 || >=18.0.0"
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
@@ -4804,38 +4790,36 @@
}
},
"node_modules/@typescript-eslint/typescript-estree": {
- "version": "6.21.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.21.0.tgz",
- "integrity": "sha512-6npJTkZcO+y2/kr+z0hc4HwNfrrP4kNYh57ek7yCNlrBjWQ1Y0OS7jiZTkgumrvkX5HkEKXFZkkdFNkaW2wmUQ==",
+ "version": "8.19.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.19.0.tgz",
+ "integrity": "sha512-WW9PpDaLIFW9LCbucMSdYUuGeFUz1OkWYS/5fwZwTA+l2RwlWFdJvReQqMUMBw4yJWJOfqd7An9uwut2Oj8sLw==",
"dev": true,
- "license": "BSD-2-Clause",
+ "license": "MIT",
"dependencies": {
- "@typescript-eslint/types": "6.21.0",
- "@typescript-eslint/visitor-keys": "6.21.0",
+ "@typescript-eslint/types": "8.19.0",
+ "@typescript-eslint/visitor-keys": "8.19.0",
"debug": "^4.3.4",
- "globby": "^11.1.0",
+ "fast-glob": "^3.3.2",
"is-glob": "^4.0.3",
- "minimatch": "9.0.3",
- "semver": "^7.5.4",
- "ts-api-utils": "^1.0.1"
+ "minimatch": "^9.0.4",
+ "semver": "^7.6.0",
+ "ts-api-utils": "^1.3.0"
},
"engines": {
- "node": "^16.0.0 || >=18.0.0"
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
- "peerDependenciesMeta": {
- "typescript": {
- "optional": true
- }
+ "peerDependencies": {
+ "typescript": ">=4.8.4 <5.8.0"
}
},
"node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": {
- "version": "9.0.3",
- "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz",
- "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==",
+ "version": "9.0.5",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
+ "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
"dev": true,
"license": "ISC",
"dependencies": {
@@ -4849,49 +4833,60 @@
}
},
"node_modules/@typescript-eslint/utils": {
- "version": "6.21.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.21.0.tgz",
- "integrity": "sha512-NfWVaC8HP9T8cbKQxHcsJBY5YE1O33+jpMwN45qzWWaPDZgLIbo12toGMWnmhvCpd3sIxkpDw3Wv1B3dYrbDQQ==",
+ "version": "8.19.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.19.0.tgz",
+ "integrity": "sha512-PTBG+0oEMPH9jCZlfg07LCB2nYI0I317yyvXGfxnvGvw4SHIOuRnQ3kadyyXY6tGdChusIHIbM5zfIbp4M6tCg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@eslint-community/eslint-utils": "^4.4.0",
- "@types/json-schema": "^7.0.12",
- "@types/semver": "^7.5.0",
- "@typescript-eslint/scope-manager": "6.21.0",
- "@typescript-eslint/types": "6.21.0",
- "@typescript-eslint/typescript-estree": "6.21.0",
- "semver": "^7.5.4"
+ "@typescript-eslint/scope-manager": "8.19.0",
+ "@typescript-eslint/types": "8.19.0",
+ "@typescript-eslint/typescript-estree": "8.19.0"
},
"engines": {
- "node": "^16.0.0 || >=18.0.0"
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
- "eslint": "^7.0.0 || ^8.0.0"
+ "eslint": "^8.57.0 || ^9.0.0",
+ "typescript": ">=4.8.4 <5.8.0"
}
},
"node_modules/@typescript-eslint/visitor-keys": {
- "version": "6.21.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.21.0.tgz",
- "integrity": "sha512-JJtkDduxLi9bivAB+cYOVMtbkqdPOhZ+ZI5LC47MIRrDV4Yn2o+ZnW10Nkmr28xRpSpdJ6Sm42Hjf2+REYXm0A==",
+ "version": "8.19.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.19.0.tgz",
+ "integrity": "sha512-mCFtBbFBJDCNCWUl5y6sZSCHXw1DEFEk3c/M3nRK2a4XUB8StGFtmcEMizdjKuBzB6e/smJAAWYug3VrdLMr1w==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@typescript-eslint/types": "6.21.0",
- "eslint-visitor-keys": "^3.4.1"
+ "@typescript-eslint/types": "8.19.0",
+ "eslint-visitor-keys": "^4.2.0"
},
"engines": {
- "node": "^16.0.0 || >=18.0.0"
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
+ "node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz",
+ "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "engines": {
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/eslint"
+ }
+ },
"node_modules/@ungap/structured-clone": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz",
diff --git a/front/package.json b/front/package.json
index 83b034f9e0e..2334b985b66 100644
--- a/front/package.json
+++ b/front/package.json
@@ -119,8 +119,8 @@
"@types/react-transition-group": "^4.4.12",
"@types/tether": "^1.4.9",
"@types/uuid": "^10.0.0",
- "@typescript-eslint/eslint-plugin": "^6.20.0",
- "@typescript-eslint/parser": "^6.20.0",
+ "@typescript-eslint/eslint-plugin": "^8.19.0",
+ "@typescript-eslint/parser": "^8.19.0",
"@vitejs/plugin-react": "^4.3.4",
"@vitejs/plugin-react-swc": "^3.7.2",
"@vitest/coverage-v8": "^2.1.8",
diff --git a/front/src/applications/editor/components/EntitySumUp.tsx b/front/src/applications/editor/components/EntitySumUp.tsx
index 4428d510e2e..0a4ef3aa079 100644
--- a/front/src/applications/editor/components/EntitySumUp.tsx
+++ b/front/src/applications/editor/components/EntitySumUp.tsx
@@ -61,6 +61,7 @@ async function getAdditionalEntities(
try {
return { [trackId]: await getEntity(infra, trackId, 'TrackSection', dispatch) };
} catch (e) {
+ console.error(e);
return {};
}
}
@@ -79,6 +80,7 @@ async function getAdditionalEntities(
);
return results;
} catch (e) {
+ console.error(e);
return {};
}
}
@@ -94,6 +96,7 @@ async function getAdditionalEntities(
);
} catch (e) {
// ignore error
+ console.error(e);
}
try {
results.exitPoint = await getEntity(
@@ -104,6 +107,7 @@ async function getAdditionalEntities(
);
} catch (e) {
// ignore error
+ console.error(e);
}
return results;
}
@@ -327,16 +331,18 @@ const EntitySumUp = ({ entity, id, objType, classes, status, error }: EntitySumU
const fetchEntities = async () => {
setState({ type: 'loading' });
- if (!entity) {
- entity = await getEntity(infraID!, id, objType as EditoastType, dispatch);
+ if (!entity && objType && id) {
+ entity = await getEntity(infraID!, id, objType, dispatch);
}
- const additionalEntities = await getAdditionalEntities(infraID!, entity, dispatch);
- setState({
- type: 'ready',
- entity,
- additionalEntities,
- });
+ if (entity) {
+ const additionalEntities = await getAdditionalEntities(infraID!, entity, dispatch);
+ setState({
+ type: 'ready',
+ entity,
+ additionalEntities,
+ });
+ }
};
fetchEntities();
diff --git a/front/src/applications/editor/components/LinearMetadata/FormComponent.tsx b/front/src/applications/editor/components/LinearMetadata/FormComponent.tsx
index 9eca10e8db2..0f929dd407f 100644
--- a/front/src/applications/editor/components/LinearMetadata/FormComponent.tsx
+++ b/front/src/applications/editor/components/LinearMetadata/FormComponent.tsx
@@ -210,6 +210,7 @@ const IntervalEditorComponent = (
}
} catch (e) {
// TODO: should we display it ?
+ console.error(e);
}
}}
/>
@@ -399,6 +400,7 @@ const IntervalEditorComponent = (
customOnChange(newData);
} catch (error) {
// TODO: Should we display the resize error ?
+ console.error(error);
} finally {
setSelectedData(newItem);
}
diff --git a/front/src/applications/editor/tools/routeEdition/components/RouteEditionLeftPanel.tsx b/front/src/applications/editor/tools/routeEdition/components/RouteEditionLeftPanel.tsx
index 6cc220abf0f..4a3f6e10490 100644
--- a/front/src/applications/editor/tools/routeEdition/components/RouteEditionLeftPanel.tsx
+++ b/front/src/applications/editor/tools/routeEdition/components/RouteEditionLeftPanel.tsx
@@ -187,6 +187,7 @@ const RouteEditionPanel = () => {
},
});
} catch (e) {
+ console.error(e);
setState({ optionsState: { type: 'idle' } });
}
}, [infraID, setState, state.entity]);
diff --git a/front/src/applications/editor/tools/selection/tool.tsx b/front/src/applications/editor/tools/selection/tool.tsx
index 196517815fe..4d5585f4599 100644
--- a/front/src/applications/editor/tools/selection/tool.tsx
+++ b/front/src/applications/editor/tools/selection/tool.tsx
@@ -218,7 +218,7 @@ const SelectionTool: Tool = {
const selection = map
.queryRenderedFeatures([
map.project(state.selectionState.rectangleTopLeft),
- map.project(position.toArray() as [number, number]),
+ map.project(position.toArray()),
])
.filter((f) => !f.layer.id.startsWith('osm'));
@@ -253,7 +253,7 @@ const SelectionTool: Tool = {
...state,
selectionState: {
...state.selectionState,
- rectangleTopLeft: position.toArray() as [number, number],
+ rectangleTopLeft: position.toArray(),
},
});
}
@@ -306,7 +306,7 @@ const SelectionTool: Tool = {
...state,
selectionState: {
...state.selectionState,
- polygonPoints: points.concat([position.toArray() as [number, number]]),
+ polygonPoints: points.concat([position.toArray()]),
},
});
}
diff --git a/front/src/applications/editor/tools/switchEdition/utils.ts b/front/src/applications/editor/tools/switchEdition/utils.ts
index f43d9768a35..f5ad4cc789b 100644
--- a/front/src/applications/editor/tools/switchEdition/utils.ts
+++ b/front/src/applications/editor/tools/switchEdition/utils.ts
@@ -29,7 +29,7 @@ export function isSwitchValid(entity: Partial, type: SwitchType):
/**
* "Flat switch" management:
*/
-export const FLAT_SWITCH_PORTS_PREFIX = 'port::' as const;
+export const FLAT_SWITCH_PORTS_PREFIX = 'port::';
export type FlatSwitchEntity = Omit<
EditorEntity,
@@ -38,7 +38,7 @@ export type FlatSwitchEntity = Omit<
objType: 'FlatSwitch';
};
-export const GROUP_CHANGE_DELAY = 'group_change_delay' as const;
+export const GROUP_CHANGE_DELAY = 'group_change_delay';
export function getSwitchTypeJSONSchema(
baseSchema: JSONSchema7,
diff --git a/front/src/applications/rollingStockEditor/views/RollingStockEditor.tsx b/front/src/applications/rollingStockEditor/views/RollingStockEditor.tsx
index c9d6a93f5cf..6be00140fc5 100644
--- a/front/src/applications/rollingStockEditor/views/RollingStockEditor.tsx
+++ b/front/src/applications/rollingStockEditor/views/RollingStockEditor.tsx
@@ -73,7 +73,7 @@ const RollingStockEditor = () => {
rollingStock={selectedRollingStock}
setIsEditing={setIsEditing}
resetFilters={resetFilters}
- isRollingStockLocked={selectedRollingStock.locked as boolean}
+ isRollingStockLocked={selectedRollingStock.locked}
/>
)}
diff --git a/front/src/common/Map/Layers/blankStyle.ts b/front/src/common/Map/Layers/blankStyle.ts
index 1cb37736273..fabfd4aab2b 100644
--- a/front/src/common/Map/Layers/blankStyle.ts
+++ b/front/src/common/Map/Layers/blankStyle.ts
@@ -13,6 +13,7 @@ const isValidUrl = async (url: string) => {
const response = await fetch(`${url}.${extension}`);
return response.ok;
} catch (error) {
+ console.error(error);
return false;
}
};
diff --git a/front/src/common/Map/Search/useSearchOperationalPoint.tsx b/front/src/common/Map/Search/useSearchOperationalPoint.tsx
index 12c3a75df3e..1a7718ac105 100644
--- a/front/src/common/Map/Search/useSearchOperationalPoint.tsx
+++ b/front/src/common/Map/Search/useSearchOperationalPoint.tsx
@@ -4,6 +4,8 @@ import { isEmpty } from 'lodash';
import { type SearchResultItemOperationalPoint, osrdEditoastApi } from 'common/api/osrdEditoastApi';
import { useInfraID } from 'common/osrdContext';
+import { setFailure } from 'reducers/main';
+import { castErrorToFailure } from 'utils/error';
import { useDebounce } from 'utils/helpers';
export const MAIN_OP_CH_CODES = ['', '00', 'BV'];
@@ -52,6 +54,7 @@ export default function useSearchOperationalPoint({
setSearchResults(results as SearchResultItemOperationalPoint[]);
} catch (error) {
setSearchResults([]);
+ setFailure(castErrorToFailure(error));
}
};
diff --git a/front/src/common/api/graouApi.ts b/front/src/common/api/graouApi.ts
index b1966c5c8ba..178cef2417d 100644
--- a/front/src/common/api/graouApi.ts
+++ b/front/src/common/api/graouApi.ts
@@ -2,6 +2,8 @@ import type {
ImportStation,
TrainScheduleImportConfig,
} from 'applications/operationalStudies/types';
+import { setFailure } from 'reducers/main';
+import { castErrorToFailure } from 'utils/error';
export const GRAOU_URL = 'https://graou.info';
@@ -12,9 +14,9 @@ export const getGraouTrainSchedules = async (config: TrainScheduleImportConfig)
});
try {
const res = await fetch(`${GRAOU_URL}/api/trainschedules.php?${params}`);
- return res.json();
+ return res.json() as Promise[]>;
} catch (error) {
- console.error(error);
+ setFailure(castErrorToFailure(error));
return null;
}
};
diff --git a/front/src/modules/infra/components/InfraSelector/InfraSelectorModalBodyEdition.tsx b/front/src/modules/infra/components/InfraSelector/InfraSelectorModalBodyEdition.tsx
index d18bd564f0e..84c2cc96eb1 100644
--- a/front/src/modules/infra/components/InfraSelector/InfraSelectorModalBodyEdition.tsx
+++ b/front/src/modules/infra/components/InfraSelector/InfraSelectorModalBodyEdition.tsx
@@ -41,6 +41,7 @@ const InfraSelectorModalBodyEdition = ({
try {
JSON.parse(await fileToValidate.text());
} catch (e) {
+ console.error(e);
setErrorMessage(t('jsonUpload.badJSON'));
return false;
}
diff --git a/front/src/modules/simulationResult/components/SimulationResultsMap/TrainHoverPosition.tsx b/front/src/modules/simulationResult/components/SimulationResultsMap/TrainHoverPosition.tsx
index 6b78e44b89b..da6644c677d 100644
--- a/front/src/modules/simulationResult/components/SimulationResultsMap/TrainHoverPosition.tsx
+++ b/front/src/modules/simulationResult/components/SimulationResultsMap/TrainHoverPosition.tsx
@@ -219,7 +219,7 @@ function TrainHoverPosition(props: TrainHoverPositionProps) {
point.tailDistanceAlong
) {
const { ecoBlocks } = get(allowancesSettings, train.id, {} as AllowancesSetting);
- const fill = getFill(isSelectedTrain as boolean, ecoBlocks);
+ const fill = getFill(isSelectedTrain, ecoBlocks);
const label = getSpeedTimeLabel(isSelectedTrain, ecoBlocks, point);
const zoomLengthFactor = getzoomPowerOf2LengthFactor(viewport);
diff --git a/front/src/modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleConfig.tsx b/front/src/modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleConfig.tsx
index fa3b5267a46..3e9cbfcfc57 100644
--- a/front/src/modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleConfig.tsx
+++ b/front/src/modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleConfig.tsx
@@ -115,7 +115,7 @@ const ImportTrainScheduleConfig = ({
setTrainsXmlData([]);
const result = await getGraouTrainSchedules(config);
- const importedTrainSchedules = validateImportedTrainSchedules(result);
+ const importedTrainSchedules = validateImportedTrainSchedules(result!);
if (importedTrainSchedules && !isEmpty(importedTrainSchedules)) {
updateTrainSchedules(importedTrainSchedules);
}
diff --git a/front/src/modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleTrainsList.tsx b/front/src/modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleTrainsList.tsx
index 4c46c9cae07..59977dcef39 100644
--- a/front/src/modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleTrainsList.tsx
+++ b/front/src/modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleTrainsList.tsx
@@ -64,7 +64,7 @@ const ImportTrainScheduleTrainsList = ({
const validTrainNameKey = findValidTrainNameKey(rollingStock);
const validTrainName = validTrainNameKey
- ? rollingstockOpenData2OSRD[validTrainNameKey as keyof typeof rollingstockOpenData2OSRD]
+ ? rollingstockOpenData2OSRD[validTrainNameKey]
: rollingStock;
return { ...train, rollingStock: validTrainName };
diff --git a/front/src/reducers/mapViewer/index.ts b/front/src/reducers/mapViewer/index.ts
index 16e596085a8..cfc0811463a 100644
--- a/front/src/reducers/mapViewer/index.ts
+++ b/front/src/reducers/mapViewer/index.ts
@@ -3,7 +3,7 @@ import { createSlice } from '@reduxjs/toolkit';
import type { InfraState } from 'reducers/infra';
import { infraState, buildInfraStateReducers } from 'reducers/infra';
-export interface MapViewerState extends InfraState {}
+export type MapViewerState = InfraState;
export const mapViewerInitialState: MapViewerState = {
...infraState,