Skip to content
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

Make the argument to init optional in the Typescript declaration too #1599

Merged
merged 1 commit into from
Jun 17, 2019

Conversation

marienz
Copy link
Contributor

@marienz marienz commented Jun 16, 2019

Pull request #1579 made the argument to the generated init() function optional (when the target is "web"), but not in the .ts.d file. This brings the two back in sync.

Tested locally, using a .ts file that mostly contains the same code the "without a bundler" example includes in its index.html.

Commit 8ace828 made the argument to the
generated init() function optional (when the target is "web"), but it is still
marked as required in the generated .d.ts file.

Fix the generated declaration to match the function definition again.
@@ -396,7 +396,7 @@ impl<'a> Context<'a> {
Ok(imports)
}

fn ts_for_init_fn(has_memory: bool) -> String {
fn ts_for_init_fn(has_memory: bool, has_module_or_path_optional: bool) -> String {
Copy link
Contributor Author

@marienz marienz Jun 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced taking a second bool flag as argument is the best interface (maybe these should be enums so it's harder to get them mixed up), but there's only one caller so maybe it's ok? If you prefer a different interface please let me know what it is and I'll change it.

(Note that I'm new to all of Rust, WebAssembly and Typescript, please don't assume I know what I'm doing :)

@alexcrichton
Copy link
Contributor

Seems reasonable to me, thanks!

@alexcrichton alexcrichton merged commit 379cad0 into rustwasm:master Jun 17, 2019
@marienz marienz deleted the typescript-init branch June 18, 2019 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants