Skip to content

Commit

Permalink
fixup! Fix optional arguments in TypeScript
Browse files Browse the repository at this point in the history
Update tests
  • Loading branch information
dbrgn committed May 9, 2019
1 parent d9c559f commit 608a819
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion crates/typescript-tests/src/opt_args_and_ret.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub fn opt_fn(_a: Option<i32>) -> Option<i32> {
/// Optional parameters followed by non-optional parameters.
/// Only the parameter _c may be marked as omittable.
pub fn opt_fn_mixed(_a: Option<i32>, _b: i32, _c: Option<i32>) -> Option<i32> {
None
}

#[wasm_bindgen]
/// Only optional parameters. All of them may be marked as omittable.
pub fn opt_fn_only(_a: Option<i32>, _b: Option<i32>, _c: Option<i32>) -> Option<i32> {
None
}
3 changes: 2 additions & 1 deletion crates/typescript-tests/src/opt_args_and_ret.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as wbg from '../pkg/typescript_tests';

const opt_fn: (a?: number) => number | undefined = wbg.opt_fn;
const opt_fn_mixed: (a: number | undefined, b: number, c?: number) => number | undefined = wbg.opt_fn_mixed;
const opt_fn_only: (a?: number, b?: number, c?: number) => number | undefined = wbg.opt_fn_only;

0 comments on commit 608a819

Please sign in to comment.