-
Notifications
You must be signed in to change notification settings - Fork 301
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
JSG_STRUCT_TS_OVERRIDE_DYNAMIC by refactoring JSG_STRUCT #2545
JSG_STRUCT_TS_OVERRIDE_DYNAMIC by refactoring JSG_STRUCT #2545
Conversation
Any chance of a test? |
I'm good with this approach but would like @kentonv to review and sign off. |
I want to add a test but how would it work? It is hard to automate a test to check whether or not types exist. I'm happy to do something if you can suggest how to test the overrides. |
55be513
to
fc2590a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the motivation for this to have RequestInitializerDict::cache
's type change based on the newly-created compat flag?
Is that actually important? It seems like we can just define the type according to the standard either way -- but without the compat flag, it'll throw (at runtime) if you actually set it.
Yes in the generated typescript.
My motivation for this is to create total equality to the initial state so without the flag the users sees no difference. However @jasnell may have other reasons for this. |
a5c15b1
to
d2ad628
Compare
IMO it's not important to prevent any observable change to the typescript types. The important thing is that we don't break workers in production, but typescript changes don't have any effect on what's already in production. |
d2ad628
to
871f24c
Compare
I disagree with this a bit. We've had a number of issues pop up due to observable changes in the types and it is something that we at least should be careful of. I don't feel strongly about this specific change, I had mentioned only to make sure any possible issues were considered. I would defer to the frameworks team (@IgorMinar @dario-piotrowicz @jculvey @vicb ) to weigh in on what to do here. |
I maintain that it is not important to ensure that So I don't think we need to bend over backwards adding new features to JSG just to avoid this. |
I don't really agree with this. The main idea behind all of our TypeScript generation work has been to make sure that the TS types match runtime behaviour as closely as possible (and the recent if (flags.getGlobalNavigator()) {
JSG_LAZY_INSTANCE_PROPERTY(navigator, getNavigator);
JSG_NESTED_TYPE(Navigator);
} |
the difference here is that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest iteration of the code looks fine. Still question the necessity but I won't block it.
Enable Dynamic TS overrides
Goal:
Enable Dynamic typescript overrides that are based on compat flags
Mechanism:
We do this by refactoring JSG_STRUCT to be more extensible in line with
JSG_RESOURCE_TYPE
.We create an internal function
registerMembersInternal
that enables no repeat code and we usec++20
requires in order to select which implementation ofregisterMembers
should be selected.Steps:
Test plan
jsg-test.c++