Skip to content

[BUG] Type error in transformToWebContainerFormat due to incompatible FileSystemTree node types #450

@CodesWithSubham

Description

@CodesWithSubham

🐛 Describe the bug

A TypeScript type error occurs in modules/webcontainers/hooks/transformer.ts when transforming a TemplateFolder into a FileSystemTree. The error is caused by a mismatch between custom file/directory interfaces and @webcontainer/api types (DirectoryNode, FileNode, SymlinkNode).


🔁 Steps to Reproduce

Steps to reproduce the behavior:

  1. Go to modules/webcontainers/hooks/transformer.ts
  2. Use transformToWebContainerFormat(template) function
  3. Run TypeScript compilation (tsc)
  4. See type error in directory assignment

✅ Expected Behavior

The function should correctly transform TemplateFolder into a valid FileSystemTree compatible with @webcontainer/api without type errors.


❌ Actual Behavior

TypeScript throws an error:

Type 'FileSystemTree' is not assignable to type '{ [key: string]: WebContainerFile | WebContainerDirectory; }'.
Type 'DirectoryNode | FileNode | SymlinkNode' is not assignable to type 'WebContainerFile | WebContainerDirectory'.

📸 Screenshots

Not applicable


🌱 Contributor Checklist

  • I am participating via GSSoC
  • I have read the contribution guidelines
  • I checked for existing issues before creating this

💻 Environment

  • Browser: Not applicable (TypeScript build issue)
  • Device: Desktop
  • OS: Any (Windows/Linux/macOS)

📝 Additional Context

The issue appears due to mixing custom WebContainerFile/WebContainerDirectory structures with official @webcontainer/api types. Alignment with FileNode and DirectoryNode is required to resolve the mismatch.

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions