Skip to content

Migrate app from JavaScript to TypeScript#893

Open
avargaskun wants to merge 9 commits intogetwud:mainfrom
avargaskun:migrate-app-to-ts
Open

Migrate app from JavaScript to TypeScript#893
avargaskun wants to merge 9 commits intogetwud:mainfrom
avargaskun:migrate-app-to-ts

Conversation

@avargaskun
Copy link
Contributor

Overview

This PR completes the migration of the app directory from JavaScript to TypeScript, modernizing the codebase with improved type safety and developer experience. Additionally, this PR fixes the broken end-to-end tests and ensures they pass throughout the migration process.

Key Changes

TypeScript Migration

  • Converted all .js files to .ts with proper ESM imports
  • Added comprehensive TypeScript type definitions for dependencies
  • Included @ts-nocheck pragmas for gradual migration support

🔧 Build & Tooling

  • Added TypeScript compilation step with npm run build
  • Implemented ts-jest for TypeScript test support
  • Added jest.config.cjs for ESM-compatible test configuration
  • Updated Dockerfile to build TypeScript and serve from /dist directory

📦 Development Dependencies

  • Installed TypeScript (^5.9.3)
  • Added @types/* packages for all major dependencies (Express, Docker, Bunyan, etc.)
  • Added ts-jest (^29.4.6) and ts-node (^10.9.2)
  • Removed babel-plugin-rewire (no longer needed with TypeScript)

🐳 Docker Updates

  • Multi-stage build now includes TypeScript compilation
  • Dev dependencies removed from final image
  • Optimized layer caching

🚀 End-to-End Testing

This PR resolves previously broken e2e tests in the e2e folder

  • ✅ Diagnosed and fixed root causes of e2e test failures
  • ✅ Verified e2e tests pass before the TypeScript migration
  • ✅ Verified e2e tests pass after the TypeScript migration
  • ✅ No regressions introduced during the migration process

Testing

All existing tests (unit and e2e) have been migrated and verified. The test suite now provides better type checking during test execution while maintaining full compatibility.

Breaking Changes

None - this is a transparent migration that maintains full backward compatibility.

Migration Strategy

  • Gradual migration path with @ts-nocheck comments where needed
  • Type definitions for external packages ensure compatibility
  • Can continue adding stricter typing in future PRs
  • End-to-end tests remain stable and passing

avargaskun and others added 5 commits December 20, 2025 12:10
- Attempting to run regex on boolean field: container.image.tag.semver
- Throwing instead of returning filtered list of tags
BUG: The logic calling `isDigestToWatch` should pass parsedImage but instead is passing the domain
CHANGE: The label `wud.watch.digest` should be respected regardless of registry
- Renamed all .js files in app/ to .ts
- Converted imports/exports to ESM syntax
- Added typescript and ts-jest dependencies
- Configured tsconfig.json and updated jest.config.cjs
- Refactored tests to support ESM and removed babel-plugin-rewire usage
- Updated Dockerfile to build TypeScript
- Added type: "module" to package.json
- Exported internal functions for testing with 'testable_' prefix
- Use commonjs to ensure compatibility
@avargaskun
Copy link
Contributor Author

@fmartinou - I hope you will consider merging. The switch to Typescript should make it safer to refactor code going forward. I kept the number of changed lines to a minimum. The change includes #874 which is needed to fix the unit tests to validate the change.

- Remove `@ts-nocheck` from `app/registry/index.ts` and component base classes.
- Create `Container` interface in `app/model/container.ts`.
- Create `Watcher` abstract base class in `app/watchers/Watcher.ts`.
- Update `Component`, `Trigger`, `Registry`, `Authentication` to be strongly typed.
- Update `Docker` watcher to extend `Watcher` and use types.
- Fix tests to align with new typing and initialization behavior.
@IARI
Copy link

IARI commented Feb 8, 2026

@fmartinou first of all thanks for this amazing project.
I really love Vue - and TypeScript would increase my motivation to use and contribute a lot (whatever that's worth)
Is there a chance you would consider this PR along with #900 ?

@avargaskun also thank you for this PR
Today several PRs got merged - and consequently there are now merge conflicts.
If possible I'll gladly assist in any way.

@fmartinou
Copy link
Collaborator

Hi @IARI ,

Thank you very much for your support. 🙏

Yes PRs regarding JavaScript to Typescript migration (both for frontend and backend parts) will eventually be merged.

Unfortunately, over the last few months, I haven't been able to set aside enough time to be responsive on the project, which is why these PRs are dragging on and conflicts are starting to pop up...

@s-b-e-n-s-o-n
Copy link

WUD-CE independently completed a full TypeScript + ESM migration across the entire codebase (app + UI, 392 files) as part of 9.0.0-ce, including Vitest 4 and Biome. Great to see upstream heading this direction too — thanks for the effort!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants