From 4729e51a582e7cee240919fa22d690c423114fa6 Mon Sep 17 00:00:00 2001 From: Darrell Huffman Date: Sat, 31 Oct 2020 20:51:04 +0100 Subject: [PATCH] reduce the number of typescript errors --- src/components/Content/Physics.tsx | 5 +- src/components/Head/index.tsx | 4 +- src/components/Header/index.tsx | 2 +- src/components/LazyDog/LazyDog.less | 36 ------------- src/components/LazyDog/index.tsx | 38 ------------- src/components/Modal/index.tsx | 11 ++-- src/components/Pagination/index.tsx | 15 ++---- .../Renderer/ForAllMankindRenderer.tsx | 5 +- src/components/Renderer/index.tsx | 7 +-- src/components/Simulator/Simulator.tsx | 4 +- .../Simulator/StarshipSimulator.tsx | 5 -- src/components/Spaceship/index.tsx | 22 ++++---- src/components/spaceship/index.tsx | 22 ++++---- src/data/scenarios/boris.json | 2 +- src/data/scenarios/jovanSystem.json | 2 +- src/data/scenarios/martianSystem.json | 2 +- src/data/scenarios/oumuamua.json | 2 +- src/physics/integrators/Euler.ts | 21 ++++++-- src/physics/integrators/KahanLi8.ts | 4 +- .../integrators/OrbitalElementsIntegrator.ts | 1 - src/physics/integrators/PEFRL.ts | 4 +- src/physics/integrators/Sofspa10.ts | 4 +- src/physics/integrators/Yoshida6.ts | 4 +- src/physics/spacecraft/SpacecraftService.ts | 5 -- src/physics/spacecraft/lambert.ts | 10 ++-- src/scene/Camera.ts | 54 +++++++++---------- src/scene/Graphics2D.ts | 2 +- src/scene/ManifestationsService.ts | 9 +++- src/scene/Spacecraft.ts | 26 ++++----- src/scene/drawManifestation.ts | 2 +- src/scene/index.js | 1 - src/state/creators/scenario.ts | 10 +++- src/state/reducers/scenario.ts | 2 +- src/templates/StarshipScenario.tsx | 6 +-- src/types/global.d.ts | 23 ++++---- src/utils.ts | 2 +- tsconfig.json | 3 +- 37 files changed, 149 insertions(+), 228 deletions(-) delete mode 100644 src/components/LazyDog/LazyDog.less delete mode 100644 src/components/LazyDog/index.tsx diff --git a/src/components/Content/Physics.tsx b/src/components/Content/Physics.tsx index e2e665937..833fecd65 100644 --- a/src/components/Content/Physics.tsx +++ b/src/components/Content/Physics.tsx @@ -10,7 +10,7 @@ interface PhysicsProps { modifyScenarioProperty: typeof modifyScenarioProperty; masses: MassType[]; integrator: string; - useBarnesHut?: boolean; + useBarnesHut: boolean; systemBarycenter: boolean; collisions: boolean; dt: number; @@ -73,7 +73,6 @@ export default ({ dropdownWrapperCssClassName="tabs-dropdown-wrapper" selectedOptionCssClassName="selected-option" optionsWrapperCssClass="options" - dynamicChildrenLen={masses.length} > {masses.map(mass => (
{masses.map(mass => (
{integrators.map(integrator => (
{ - const [loading, setLoading] = useState(true); - - return ( -
- setLoading(false)} - src={src} - alt={alt} - width={width} - height={height} - className={!loading && "loaded-image"} - style={{ width: !width && "100%" }} - /> -

{caption}

- {loading && } -
- ); -}; diff --git a/src/components/Modal/index.tsx b/src/components/Modal/index.tsx index 1769540a4..c6670556d 100644 --- a/src/components/Modal/index.tsx +++ b/src/components/Modal/index.tsx @@ -1,16 +1,11 @@ -import React, { - ReactElement, - MouseEvent, - ReactChildren, - ReactChild -} from "react"; +import React, { ReactElement, MouseEvent, ReactNode } from "react"; import "./Modal.less"; interface ModalProps { - children: ReactChildren | ReactChild; + children: ReactNode; callback: (event: MouseEvent) => void; modalWrapperCssClass: string; - modalCssClass: string; + modalCssClass?: string; } export default ({ diff --git a/src/components/Pagination/index.tsx b/src/components/Pagination/index.tsx index b87c09f9b..b59c5512c 100644 --- a/src/components/Pagination/index.tsx +++ b/src/components/Pagination/index.tsx @@ -15,14 +15,8 @@ interface PaginationProps { }; } -export default ({ - itemsPerPage, - pagination -}: PaginationProps): ReactElement => { - const renderRange = ( - range: { start: number; end: number }, - itemsPerPage: number - ) => { +export default ({ pagination }: PaginationProps): ReactElement => { + const renderRange = (range: { start: number; end: number }) => { const items = [ First Page @@ -49,10 +43,7 @@ export default ({ return ( ); }; diff --git a/src/components/Renderer/ForAllMankindRenderer.tsx b/src/components/Renderer/ForAllMankindRenderer.tsx index 831e6ff72..243c9a52c 100644 --- a/src/components/Renderer/ForAllMankindRenderer.tsx +++ b/src/components/Renderer/ForAllMankindRenderer.tsx @@ -1,7 +1,6 @@ import React, { memo, ReactElement, useEffect, Fragment, useRef } from "react"; import forAllMankindScene from "../../scene/forAllMankindScene"; import "./Renderer.less"; -import { resetScenario } from "../../state/creators/scenario"; interface RendererProps { scenarioName: string; @@ -11,20 +10,18 @@ export default memo( ({ scenarioName }: RendererProps): ReactElement => { const graphics2DCanvas = useRef(null); const webGlCanvas = useRef(null); - const audio = useRef(null); useEffect(() => { scenarioName && forAllMankindScene .reset() - .init(webGlCanvas.current, graphics2DCanvas.current, audio.current); + .init(webGlCanvas.current, graphics2DCanvas.current); }); return ( - ); }, diff --git a/src/components/Renderer/index.tsx b/src/components/Renderer/index.tsx index 97394dc83..f5b488335 100755 --- a/src/components/Renderer/index.tsx +++ b/src/components/Renderer/index.tsx @@ -1,7 +1,6 @@ import React, { memo, ReactElement, useEffect, Fragment, useRef } from "react"; import scene from "../../scene"; import "./Renderer.less"; -import { resetScenario } from "../../state/creators/scenario"; interface RendererProps { scenarioName: string; @@ -11,20 +10,16 @@ export default memo( ({ scenarioName }: RendererProps): ReactElement => { const graphics2DCanvas = useRef(null); const webGlCanvas = useRef(null); - const audio = useRef(null); useEffect(() => { scenarioName && - scene - .reset() - .init(webGlCanvas.current, graphics2DCanvas.current, audio.current); + scene.reset().init(webGlCanvas.current, graphics2DCanvas.current); }); return ( - ); }, diff --git a/src/components/Simulator/Simulator.tsx b/src/components/Simulator/Simulator.tsx index 126eed882..a3e2d48f5 100755 --- a/src/components/Simulator/Simulator.tsx +++ b/src/components/Simulator/Simulator.tsx @@ -183,9 +183,9 @@ export default ({ }} className="iframe-scroll-wrapper" /> - ) : ( + ) : scenarioWikiUrl ? (