-
Notifications
You must be signed in to change notification settings - Fork 19
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
Generate Typescript documentation from wit files #1157
base: main
Are you sure you want to change the base?
Generate Typescript documentation from wit files #1157
Conversation
|
The core changes are done, but I still need to debug an issue with the npm tests. After these changes Jest is not able to resolve the module imports, even though |
… .d.ts files using the `jco types` command. This command is better for our use case than `jco transpile` because it generates the declarations directly from the source .wit files, whereas `jco transpile` uses the WASM binaries to generate them. This means that `jco types` has access to the documentation that's written in the wit interfaces, and `jco transpile` does not. Since we're generating the interfaces in a separate step, I'm disabling typescript in the original `jco transpile` step. This is just a precaution to avoid confusion or possible conflicting declaration files interferring with each other.
…is correctly propagating through the build process.
…rpose of this is so that both processes use the same `CodegenFileSystem` instance. If they used separate instances, then the files generated in one function would get deleted by the next.
8e79c75
to
096ad6d
Compare
Cargo.toml
Outdated
@@ -151,7 +151,8 @@ thiserror = { version = "1.0.68" } | |||
toml = { version = "0.8.19" } | |||
trybuild = { version = "1.0.101" } | |||
url = { version = "2.4.1", features = ["serde"] } | |||
wasm-tools = { version = "1.216.0" } | |||
wasm-tools = { version = "1.202.0" } |
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 this downgrade intended? not sure I understand the reason.
Also, nit blank lines.
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.
No, this was leftover from a different change I was testing, which involved bringing in a local version wasm-tools
in order to make some changes.
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.
I think Cargo.lock
is left still.
crates/codegen/runtime/npm/package/wasm/generated/interfaces/nomic-foundation-slang-parser.d.ts
Show resolved
Hide resolved
crates/codegen/runtime/npm/package/wasm/generated/interfaces/nomic-foundation-slang-cst.d.ts
Show resolved
Hide resolved
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.
Left a few questions.
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.
I think there is still one remaining issue, but otherwise, LGTM.
This PR uses the
jco types
command to generate Typescript definitions for the wasm crates instead ofjco transpile
. The reason is thatjco transpile
generates ts definitions by decoding WASM component binaries, whereasjco types
parses .wit files directly and uses that information. This means that theResolve
instance created duringtypes
has access to the type documentation info, and the one created duringtranspile
does not.I've modified
infra check npm
with a new step which callsjco types
and handles the resulting .d.ts files. When callingjco transpile
we're now passing the option--no-typescript
to avoid generating conflicting typescript outputs.These changes depend on NomicFoundation/jco#1, which augments the
types
command to accept the same configuration file that we pass totranspile
. Without this, the codegen intypes
will not be able to generate Typescript enums for Rust enums, or any other customization that we want.