Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H-86: Add minor hEngine compatibility with TypeScript for behaviors and initialization #41

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rivertam
Copy link

@rivertam rivertam commented Sep 4, 2023

This Pull Request has been brought over from hashintel/hash#2651. My (@rivertam) current thoughts are that this shouldn't be merged without also adding support for import in some capacity. However, I'm holding off on that at least for now as that's probably a bigger project. David told me you're going to come out with a blog post about the future of the engine, so I'm at least holding off until that.


Original PR contents (more discussion can be found on the original PR)

Preamble

I'm really interested in this project, both as a user and as a potential contributor. I have a bespoke simulation framework that I've been toying with and would be interested in trying to merge some of the work I've done on it to Hash engine to see if it's useful. I'd love to take some conversations offline and I plan on messaging in the Discord, but just fyi I'm open to hopping on a video call to have higher throughput.

This PR isn't so much "I want to merge this" as it is "I wanted to get familiar enough with the internals to be able to do this", and I've spent the last couple of weeks reading through and trying to figure out how the project works from the inside. I've certainly made progress, but I'm sure guidance would help me speed up! In terms of this PR, I do need to do more thorough testing and add automated tests and I'm sure other things that are part of the process, but I wanted to submit for feedback first to avoid wasting my time. Think of this as a very involved Discussion rather than a PR, maybe.

I have a couple of ideas on things I want to work on after this PR (see next steps), but the long-and-short is that I'm interested in using swc_bundler to make it possible to split up complex logic (and maybe get rid of some temporary hacks on the worker).

🌟 What is the purpose of this PR?

This uses the swc compiler to strip the TypeScript types from behavior files named <something>.ts and initialization files named init.ts

🔍 What does this change?

This adds a compilation step to the simulation executor for initialization and for behavior execution

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

Confirm you have taken the necessary action to record a changeset or publish a change, as appropriate

I absolutely have not and am not sure how to do this! TBD

This PR:

  • modifies a Cargo-publishable library, but it is not yet ready to publish
  • I am unsure / need advice

📜 Does this require a change to the docs?

The changes in this PR:

  • requires changes to docs
    • I'm not sure if this should even be merged considering all it does is strip types (and not check them)
    • If it were to be merged, I think the docs could reflect that TypeScript is supported in these places

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • I am unsure / need advice
    • I added swc to Cargo.toml, but I'm not sure if that's involved with the Turbo Graph or if that's just npm

⚠️ Known issues

  • No type checking
  • No exported types that are useful

🐾 Next steps

Great question

  • Export types that can be used in TypeScript (somehow)
  • Check types using tsc (is this out of scope? might be better to just leave this to editors/the web client)
  • Personally, the next thing I want to work on is adding swc_bundler to the manifest stage so we can split the init and behavior files into multiple files, which I think is currently unsupported (please correct me if I'm wrong!). While this wouldn't much help close out the "add TypeScript support" checkbox, it's what I want next as a user.

🛡 What tests cover this?

  • None! I am definitely interested in adding tests but I wanted to get feedback before wasting my time!

❓ How to test this?

  • So far, I've just converted the most basic project (the one with 2 agents with ages 0 and 5 going up) to TypeScript. It's so minimal it's bad! I've attached the project I'm using.

ageing-agents.ts.tar.gz

📹 Demo

I guess here ya go!

https://asciinema.org/a/ee9BQceUMV0t5OTAiWw7icy76

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

Successfully merging this pull request may close these issues.

2 participants