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

fix: Optional JSDoc @param #3577

Merged
merged 2 commits into from Aug 29, 2023
Merged

Conversation

magic-akari
Copy link
Contributor

Copy link
Collaborator

@daxpedda daxpedda left a comment

Choose a reason for hiding this comment

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

Could you add a note in the changelog?
Otherwise looks great!

@Liamolucko
Copy link
Collaborator

An issue I can see here is that this will currently produce optional parameters before required parameters; e.g. this function:

#[wasm_bindgen]
pub fn foo(a: Option<i32>, b: i32) {}

generates this JSDoc:

/**
* @param {number | undefined} [a]
* @param {number} b
*/

a is marked as optional even though b is required, so it's impossible to actually leave it out.

I wasn't sure if this actually mattered, but it seems like it does because TypeScript complains about it:

test.js(5,17): error TS1016: A required parameter cannot follow an optional parameter.

@magic-akari
Copy link
Contributor Author

An issue I can see here is that this will currently produce optional parameters before required parameters; e.g. this function:

@Liamolucko You are right. I think it should be handled by reversing the order like typescript_signature.

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@daxpedda daxpedda left a comment

Choose a reason for hiding this comment

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

LGTM!
Thanks @Liamolucko for catching that.

@daxpedda daxpedda merged commit 99983c8 into rustwasm:main Aug 29, 2023
25 checks passed
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.

JSDoc: Option @param syantax missing
3 participants