Skip to content

The unofficial TypeScript client for the Phoenix web framework - WIP

Notifications You must be signed in to change notification settings

tylerbarker/phoenix_ts

Repository files navigation

phoenix_ts

phoenix_ts is, first and foremost, an experiment and a learning exercise. It's an attempt to port the JS library bundled with the Phoenix web framework (as of v1.7.12) to TypeScript. Bundled and tested with Bun.

I'll be doing the same for phoenix_live_view in a separate repo at a later date. Great timing actually, as they just announced a release candidate for v1.0!

This effort isn't officially endorsed by the Phoenix team, just a bit of fun. That being said, I would love it if this or a similar effort was eventually integrated into the Phoenix project. Personally, I think it'd be easier to maintain, extend, and consume the framework if the JS clients were written in TypeScript and shipped types.

TODO

  • Port the Mocha test suite to Bun test (3x speedup!)
  • Port util.js to TypeScript
  • Port constants.js to TypeScript
  • Port index.js to TypeScript
  • Port ajax.js to TypeScript
  • Port timer.js to TypeScript
  • Port serializer.js to TypeScript
  • Port push.js to TypeScript
  • Port longpoll.js to TypeScript
  • Port channel.js to TypeScript
  • Port presence.js to TypeScript
  • Port socket.js to TypeScript
  • Circle back to any types after everything is ported
  • Circle back to as type assertions after everything is ported
  • Reassess bundling targets e.g what do we need to support?
  • Configure as Hex package (minimal Elixir scaffolding)
  • Write installation documentation

Staying Up to Date

I intend to release a corresponding version of this library for each Phoenix release from v1.7.12 onwards, even if the bundled JS does not change to assure compatibility.

I've written a script - to be run every day by a GH Action - which:

  1. Checks the Phoenix repo for releases newer than our current version.
  2. If a new release is found, it raises an issue on this repo with details of any changes to the Phoenix assets/ repo if they are present.

See phx-changes-check.ts.

Development

To install dependencies:

bun install

To build:

bun run build

We run the tests only against the generated JavaScript - so you must build the project before running the suite. Once that's done, run the tests:

bun test

This project was created using bun init in bun v1.1.7. Bun is a fast all-in-one JavaScript runtime.

About

The unofficial TypeScript client for the Phoenix web framework - WIP

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published