tsc fixes and rules

This commit is contained in:
2026-02-28 01:10:14 +01:00
parent ae02080563
commit a643f24452
7 changed files with 26 additions and 13 deletions

View File

@@ -0,0 +1,12 @@
# Project Architecture
This is a React application with:
- Components in `/src/components`
- State management using zustand in `/src/stores`
## Coding Standards
- Use TypeScript for all new files
- Follow the existing naming conventions
- Write tests for all new features

View File

@@ -1,6 +1,6 @@
import React, { createContext, useEffect, useEffectEvent, useState } from 'react'; import React, { useEffect, useEffectEvent, useState } from 'react';
import { Layout, theme, Breadcrumb, Button, Space, Tree, type TreeDataNode } from 'antd'; import { Layout, theme, Breadcrumb, Button, Space, Tree } from 'antd';
import Graph, { GraphModel } from './components/Graph'; import Graph from './components/Graph';
import type { BreadcrumbItemType } from 'antd/es/breadcrumb/Breadcrumb'; import type { BreadcrumbItemType } from 'antd/es/breadcrumb/Breadcrumb';
import { useKeysdownStore } from './stores/ArrayStore'; import { useKeysdownStore } from './stores/ArrayStore';
import { import {

View File

@@ -1,4 +1,6 @@
export function graphToDot(g) { import type { GraphModel } from "./components/Graph";
export function graphToDot(g: GraphModel): string {
// Directed graph, use neato layout so we can use pos attributes // Directed graph, use neato layout so we can use pos attributes
const lines = []; const lines = [];
lines.push('digraph G {'); lines.push('digraph G {');

View File

@@ -103,7 +103,7 @@ export default function Graph({ setGraphPath }: { setGraphPath: React.Dispatch<R
graphsPath.push(createPathSegment(nodeContext.nodeId, nodeContext.nodeName)); graphsPath.push(createPathSegment(nodeContext.nodeId, nodeContext.nodeName));
setGraphsPath([...graphsPath]) setGraphsPath([...graphsPath])
} }
const state = useGraphsStore.getState(); const state = useGraphsStore.getState() as { graphsById: Map<string, GraphModel> };
const graphsById = state.graphsById; const graphsById = state.graphsById;
const graph = graphsById.get(graphId); const graph = graphsById.get(graphId);
if (graph) { if (graph) {
@@ -118,8 +118,8 @@ export default function Graph({ setGraphPath }: { setGraphPath: React.Dispatch<R
const svgElement = await viz.renderSVGElement(dot, { engine: 'dot' }); const svgElement = await viz.renderSVGElement(dot, { engine: 'dot' });
const container = containerRef.current; const container = containerRef.current;
if (!container) return; if (!container) return;
container.innerHTML = ''; (container as HTMLElement).innerHTML = '';
container.appendChild(svgElement); (container as HTMLElement).appendChild(svgElement);
attachInteractions(svgElement); attachInteractions(svgElement);
} catch (e) { } catch (e) {
console.error('Viz render error', e); console.error('Viz render error', e);

View File

@@ -1,5 +1,5 @@
import { Dropdown, type MenuProps } from "antd"; import { Dropdown, type MenuProps } from "antd";
import { defaultGraph, graphContext, type EdgeModel, type NodeContext } from "./Graph"; import { defaultGraph, graphContext, GraphModel, type EdgeModel, type NodeContext } from "./Graph";
import { useContext } from "react"; import { useContext } from "react";
import { cloneDeep } from "lodash"; import { cloneDeep } from "lodash";
import { useGraphsStore } from "../stores/GraphsStore"; import { useGraphsStore } from "../stores/GraphsStore";
@@ -39,7 +39,7 @@ export default function NodeContextMenu({
} }
const graphContextValue = useContext(graphContext)!; const graphContextValue = useContext(graphContext)!;
const graphsById = useGraphsStore((s) => s.graphsById); const graphsById = useGraphsStore((s) => (s as { graphsById: Map<string, GraphModel> }).graphsById);
const addTreeNode = useGraphLayersTreeStore(store => store.add); const addTreeNode = useGraphLayersTreeStore(store => store.add);
function contextMenuOpenChange(open: boolean) { function contextMenuOpenChange(open: boolean) {

View File

@@ -1,5 +1,4 @@
import type { TreeDataNode } from "antd"; import type { TreeDataNode } from "antd";
import { cloneDeep } from "lodash";
import React from "react"; import React from "react";
import { create } from "zustand"; import { create } from "zustand";
import type { NodeContext } from "../components/Graph"; import type { NodeContext } from "../components/Graph";
@@ -13,7 +12,7 @@ export interface TreeStore {
remove: (nodeId: string) => void; remove: (nodeId: string) => void;
} }
export const useGraphLayersTreeStore = create<TreeStore>()((set, get) => ({ export const useGraphLayersTreeStore = create<TreeStore>()((set) => ({
nodesFlatById: new Map<React.Key, TreeDataNode>(), nodesFlatById: new Map<React.Key, TreeDataNode>(),
parentIdByChildId: new Map<React.Key, string>(), parentIdByChildId: new Map<React.Key, string>(),
rootNodes: [], rootNodes: [],

View File

@@ -1,9 +1,9 @@
{ {
"compilerOptions": { "compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2022", "target": "es2020",
"useDefineForClassFields": true, "useDefineForClassFields": true,
"lib": ["ES2022", "DOM", "DOM.Iterable"], "lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext", "module": "ESNext",
"types": ["vite/client"], "types": ["vite/client"],
"skipLibCheck": true, "skipLibCheck": true,