upgrade react-app to typescript 4

Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
This commit is contained in:
Augustin Husson 2021-09-05 18:58:46 +02:00
parent 143fce73cd
commit 405198f430
6 changed files with 16 additions and 13 deletions

View file

@ -77,7 +77,7 @@
"prettier": "^2.3.2", "prettier": "^2.3.2",
"react-scripts": "4.0.3", "react-scripts": "4.0.3",
"sinon": "^9.0.3", "sinon": "^9.0.3",
"typescript": "^3.3.3" "typescript": "^4.4.2"
}, },
"optionalDependencies": { "optionalDependencies": {
"fsevents": "^2.3.2" "fsevents": "^2.3.2"
@ -22808,9 +22808,9 @@
} }
}, },
"node_modules/typescript": { "node_modules/typescript": {
"version": "3.9.10", "version": "4.4.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.2.tgz",
"integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", "integrity": "sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==",
"dev": true, "dev": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
@ -43168,9 +43168,9 @@
} }
}, },
"typescript": { "typescript": {
"version": "3.9.10", "version": "4.4.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.2.tgz",
"integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", "integrity": "sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==",
"dev": true "dev": true
}, },
"unbox-primitive": { "unbox-primitive": {

View file

@ -92,7 +92,7 @@
"prettier": "^2.3.2", "prettier": "^2.3.2",
"react-scripts": "4.0.3", "react-scripts": "4.0.3",
"sinon": "^9.0.3", "sinon": "^9.0.3",
"typescript": "^3.3.3" "typescript": "^4.4.2"
}, },
"proxy": "http://localhost:9090", "proxy": "http://localhost:9090",
"jest": { "jest": {

View file

@ -34,7 +34,8 @@ export const useFetch = <T extends Record<string, any>>(url: string, options?: R
const json = (await res.json()) as APIResponse<T>; const json = (await res.json()) as APIResponse<T>;
setResponse(json); setResponse(json);
setIsLoading(false); setIsLoading(false);
} catch (error) { } catch (err: unknown) {
const error = err as Error;
setError(error); setError(error);
} }
}; };

View file

@ -200,7 +200,8 @@ class Panel extends Component<PanelProps, PanelState> {
loading: false, loading: false,
}); });
this.abortInFlightFetch = null; this.abortInFlightFetch = null;
} catch (error) { } catch (err: unknown) {
const error = err as Error;
if (error.name === 'AbortError') { if (error.name === 'AbortError') {
// Aborts are expected, don't show an error for them. // Aborts are expected, don't show an error for them.
return; return;

View file

@ -10,10 +10,11 @@ const EndpointLink: FC<EndpointLinkProps> = ({ endpoint, globalUrl }) => {
let url: URL; let url: URL;
try { try {
url = new URL(endpoint); url = new URL(endpoint);
} catch (e) { } catch (err: unknown) {
const error = err as Error;
return ( return (
<Alert color="danger"> <Alert color="danger">
<strong>Error:</strong> {e.message} <strong>Error:</strong> {error.message}
</Alert> </Alert>
); );
} }

View file

@ -17,7 +17,7 @@
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"noEmit": true, "noEmit": true,
"jsx": "react", "jsx": "react-jsx",
"noFallthroughCasesInSwitch": true "noFallthroughCasesInSwitch": true
}, },
"include": [ "include": [