Add nice type generation for ctx.exports and ctx.props.#5004
Conversation
7bbe709 to
ab815e7
Compare
d142c62 to
8848e56
Compare
|
(rebased) |
|
I've updated this so |
37d18f9 to
251750b
Compare
251750b to
cd74ead
Compare
On all of: * ExecutionContext * DurableObjectState * WorkerEntrypoint * DurbaleObject
I noticed this list was out-of-date compared to rtti.c++. Note I couldn't add modules.h nor pyodide.h as they don't seem to be declare dependencies. Unclear if that's important. This doesn't seem to have had any effect on the generated types, so I'm not sure whether it matters, but the comment seemed to suggest this list should be kept in sync with rtti.c++.
This also works around issue #4882 in the type generation by overriding `$class` to `class` manually.
Unfortunately I cannot figure out how to run this locally, so I'm testing in CI.
I think there's no real reason to let you override this?
Decided I need to do this in order to get the ball rolling, but this commit can easily be reverted later when we're ready.
cd74ead to
eeae70a
Compare
|
This breaks my typechecking - is there a way to opt out of generating the |
|
@shmuli9 This PR does not implement the |
|
Ah, thanks for that @kentonv. I was under the impression this PR implemented it, so thanks for the info Also, thanks for contributing to this repo 💪 - didn't mean to be personal in my bug report. I just thought this was the place for it. Definitely appreciate the active development here 👨💻 |
This makes
ctx.exportshave the right types automatically, as long as the project has a type override like:Also:
Envto beCloudflare.Envinstead ofunknownin several places.ctx.propstoWorkerEntrypointandDurableObject. Unfortunately it has to be the second parameter, afterEnv, which is annoying since it'd be nice to leaveEnvas the default. Maybe if we rename these toStatelessWorker/StatefulWorkerwe can change the parameter order at that time to make props first?DO NOT MERGE this untilI added back the experimental guard so that I can land this.ctx.exportsis verified as working in prod: I unmarked it "experimental" because otherwise it was going to be annoying to maintain separate overrides. We are very close on this so I think it'll be OK.