Skip to content

typescript: replace widespread ny type usage with proper interfaces in playground components #145

Description

@piyushdotcomm

Problem

Multiple components use any types extensively instead of proper TypeScript types. This defeats TypeScript's type safety and makes it harder to catch bugs at compile time.

Instances Found

modules/playground/components/MainPlaygroundPage.tsx

  • Line 64: interface MainPlaygroundPageProps { initialData: any; ... }initialData should be typed as the Playground+TemplateFile shape
  • Line 70: rawContent derived from initialData?.templateFiles?.[0]?.content as untyped

modules/playground/components/playground-header.tsx

  • Line 25: playgroundData: any;
  • Line 28: activeFile: any;

modules/playground/components/collaboration-avatars.tsx

  • Line 7: const [users, setUsers] = useState<any[]>([]);

modules/playground/components/ai-chat-panel.tsx

  • Line 340: {messages.map((msg: any) => {
  • Line 341: const rawParts: any[] = (msg as any).parts ?? [];
  • Lines 345, 347, 353: multiple (p: any) usages

modules/playground/components/playground-editor.tsx

  • Line 49: const handleEditorDidMount = (editor: any, monaco: Monaco) => {
  • Line 61: editor.onDidChangeCursorPosition((e: any) => {

Expected Fix

Define proper interfaces for:

  1. PlaygroundData (playground + template files shape from Prisma)
  2. ActiveFile (TemplateFile extended with hasUnsavedChanges)
  3. CollaboratorUser (name + color shape from Yjs awareness)

Then replace any usage with these typed interfaces.

Why This Matters

  • TypeScript errors are already suppressed in builds (ignoreBuildErrors: true) — fixing any types is a prerequisite to safely re-enabling type checking
  • any in the message types means AI chat bugs won't be caught by the compiler
  • The initialData: any means a malformed server response could crash the playground silently

Files Affected

  • modules/playground/components/MainPlaygroundPage.tsx
  • modules/playground/components/playground-header.tsx
  • modules/playground/components/collaboration-avatars.tsx
  • modules/playground/components/ai-chat-panel.tsx
  • modules/playground/components/playground-editor.tsx

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions