Skip to content

Commit ea74d46

Browse files
committed
Migrate canvas & editor components to TypeScript
Convert StoryCanvas, ChoiceConditionsEditor, ChoiceEffectsEditor, and StoryDiagnostics from JavaScript to TypeScript. Add proper prop interfaces, generic type parameters for React Flow nodes/edges, and export GraphHealthNode for type reuse. Removes type-casting workarounds in App.tsx by using proper component types.
1 parent 27bb76d commit ea74d46

6 files changed

Lines changed: 924 additions & 803 deletions

File tree

src/App.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import ImportProjectModal from "./components/editor/ImportProjectModal";
1919
import useStoryState, {
2020
type UseStoryStateResult,
2121
} from "./hooks/useStoryState";
22-
import usePlayState, { type UsePlayStateResult } from "./hooks/usePlayState";
22+
import usePlayState from "./hooks/usePlayState";
2323
import useOnboarding from "./hooks/useOnboarding";
2424
import {
2525
downloadStoryPlayExportV1,
@@ -44,7 +44,6 @@ import {
4444
type PrepareStoryPlayImportResult,
4545
} from "./utils/importStoryPlayProject";
4646
import type { MiniGameEditorDraft } from "./hooks/useMiniGameEditorState";
47-
import type { StoryVariables } from "./types/story";
4847

4948
declare global {
5049
interface Window {
@@ -57,15 +56,6 @@ declare global {
5756

5857
type EditorActiveScreen = "editor" | "variables" | "characters";
5958

60-
/**
61-
* App-side props for still-JS StoryCanvas. allowJs infers `characters = []` as
62-
* `never[]`, which rejects StoryCharacter[].
63-
*/
64-
type StoryCanvasAppProps = UseStoryStateResult & {
65-
currentPlayNodeId: UsePlayStateResult["currentPlayNodeId"];
66-
playVariables: StoryVariables;
67-
};
68-
6959
/**
7060
* App-side props for still-JS SidebarEditor. allowJs infers
7161
* `onboardingStepId = null` as only `null`, rejecting real step id strings.
@@ -76,7 +66,6 @@ type SidebarEditorAppProps = UseStoryStateResult & {
7666
onOpenVariables?: () => void;
7767
};
7868

79-
const StoryCanvasView = StoryCanvas as unknown as ComponentType<StoryCanvasAppProps>;
8069
const SidebarEditorView =
8170
SidebarEditor as unknown as ComponentType<SidebarEditorAppProps>;
8271

@@ -570,7 +559,7 @@ function EditorApp() {
570559
.join(" ")}
571560
>
572561
<section className="panel canvas-panel" data-onboarding="canvas">
573-
<StoryCanvasView
562+
<StoryCanvas
574563
{...story}
575564
currentPlayNodeId={play.currentPlayNodeId}
576565
playVariables={play.playVariables}

0 commit comments

Comments
 (0)