Description
While this is not actually likely to be a real usage issue.
When generated types are consumed (in particular from a guest, for example), it is possible that WIT namespaces and packages are identically named (along with all their possible exports, fns, resources, etc) -- it seems like there would be an issue (whether at editor/tooling level or as a barrier to tsc
) in working out the types.
Another possible issue here is the .wit.d.ts
file that is generated that sits at the root of the generated code. The worry is that this file my have two exports (as in exports * from "./interfaces/something"
) that would collide.
For reference the "recommended" way to use generated types from Typescript is to modify tsconfig.json
and modify the compilerOptions.paths
config to something like this:
"paths": {
"wasi:http/types@0.2.3": [ "./generated/types/interfaces/wasi-http-types.d.ts" ]
},
For example see wasmcloud's http-hello-world)
Wiring imports via tsconfig.json
would obviously solve the issue, but it's unclear if this is what we recommend everywhere/if there is proper documentation around this. It seems more likely that someone might do the following:
import { .. } from "../../generated";
(and in fact, we've seen a bug filed with this usage)
Until jco
automatically updates/edits tsconfig.json
and we strongly encourage only using imports of the actual package/namespace (i.e. import { .... } from "ns:pkg/interface@v.v.v"
), we probably are exposed to this possibility.
It would be great to have:
- automated test around this problem,
- automation for downloading and installing jco + use of jco from a test context
- a test to ensure a trivial project & toolchain works as we expect
We kind of already have (2) and (3) as we do test examples that are in-repo (via running npm run all
for all examples), but it would be nice to be more explicit here, so we have a harness for testing e2e from a user's perspective.