-
Notifications
You must be signed in to change notification settings - Fork 81
Incorrect types for preview2-shim
package
#708
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
Comments
Hey @konall thanks for pointing out the issue! A PR would definitely be appreciated -- I can make sure to review it ASAP and get it merged. |
In putting this PR together I've found that the Is there a way I could address this? |
Ah, so that's a bit of a conundrum -- I think the best way forward for this might be to incorporate the version into the constructor (ideally, as part of the object already going in, somewhere), and use a reasonable default (usually dictated by componentize-js underneath). When building the import object we can use the version as appropriate with the interface (e.g. That said, I'm really surprised this was an issue -- would you mind adding a regression test along with your PR? I think the only examples we have right now must not use a versioned WASI which is odd. |
I may be misunderstanding your suggestion, but how would |
Unfortunately, My hope was that we could use some of Typescript's advanced features (in particular template literal types) to generate the right type, on the shim side. Does that make sense? I'm hoping we can essentially do something like this: type WASIImportObject<Version> = {
"wasi:cli/environment@${Version}": typeof import("./interfaces/wasi-cli-environment.d.ts");
//...
} |
Excuse my ignorance here, just trying to wrap my head around this! I was initially confused as to how we could arrive at a sensible default version, given that the I'm also wondering if this issue signals a need for broader changes, as there are other instances besides this where "version-less" imports of WASI worlds are assumed; the |
No problem!
So we can't really -- what we can do is mostly rev versions, and benefit from the fact that newer non-semver-breaking versions of the implementations are backwards compatible (i.e. it's fine to use
Concretely what broader changes are you envisioning here? Even a basic sketch would be nice -- would love to hear what you think here! |
Ah I see, that makes sense regarding the semver, thanks for the clarification! By "broader changes" I meant that changing the type declarations here will apparently impact other parts of the codebase too- I'm not too familiar with the internals so it's hard for me to pinpoint exactly where to look for functionality that would break if versioned WASI imports are enforced. |
Ah that's a good question -- so right now I think as long as you change only the typing, we shouldn't have a problem. While the bindings don't have the right type right now, they're still usable (we have tests for this IIRC) from JS.
I think we can start strict and require a version to be specified and loosen in the future, if needed -- at present all WASI APIs are versioned and will be into the future, so realistically going forward no one should be trying to use an unversioned WASI API. Multiple versions of a WASI world are certainly possible -- but I'd expect someone to make multiple |
Having done some digging, I think I can reframe some of the points I raised; rebasing the issue for clarity:
Two other side-notes:
|
Thanks for restating everything and producing a clear writeup!
The tension here is that we want the types generated for The main reason we want this is so that we can use newer semver-compatible versions of Consider the case where we released a new version of We do something similar with component exports themselves: // ...
export { incomingHandler023 as incomingHandler, incomingHandler023 as 'wasi:http/[email protected]', } We essentially export a versionless and versionful representation of the same export. There are at least a few ways forward here:
IMO removing the versions from the generated instantiate is a nonstarter because that information at least denotes the lower bound of what the component expects. I think I'm leaning towards (1) here.
I'm not sure I'd characterize it as a big task, but the potential to break things is large -- we might want to introduce this behavior and control it with a flag first. That said, the actual implementation in the codebase should be fairly straight forward (i.e. removing where we strip the versions). A lot of tests would break immediately though. |
Hi there, thanks for all the work on this great project!
Unless I'm missing something, it seems that the types for the
preview2-shim
package don't match the implementation.Would it be possible to release a new version of the package with matching types please? Let me know if it would be helpful for me to submit a PR.
Thanks!
The text was updated successfully, but these errors were encountered: