mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 10:10:52 +00:00
commit
ae47665b4d
@ -1,11 +0,0 @@
|
||||
import * as wbg from './pkg/typescript_tests';
|
||||
import * as wasm from './pkg/typescript_tests_bg';
|
||||
|
||||
const a1: (a: string) => void = wbg.greet;
|
||||
const a2: (a: number, b: number) => void = wasm.greet;
|
||||
const a3: WebAssembly.Memory = wasm.memory;
|
||||
|
||||
const c = new wbg.A();
|
||||
wbg.A.other();
|
||||
c.foo();
|
||||
c.free();
|
11
crates/typescript-tests/src/custom_section.rs
Normal file
11
crates/typescript-tests/src/custom_section.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(typescript_custom_section)]
|
||||
const TS_INTERFACE_EXPORT: &'static str = r"
|
||||
interface Height { height: number; }
|
||||
";
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub struct Person {
|
||||
pub height: u32,
|
||||
}
|
3
crates/typescript-tests/src/custom_section.ts
Normal file
3
crates/typescript-tests/src/custom_section.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import * as wbg from '../pkg/typescript_tests';
|
||||
|
||||
const height: wbg.Height = new wbg.Person();
|
@ -1,20 +1,4 @@
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn greet(_: &str) {}
|
||||
|
||||
#[wasm_bindgen]
|
||||
struct A {
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
impl A {
|
||||
#[wasm_bindgen(constructor)]
|
||||
pub fn new() -> A {
|
||||
A {}
|
||||
}
|
||||
|
||||
pub fn other() {}
|
||||
|
||||
pub fn foo(&self) {}
|
||||
}
|
||||
mod custom_section;
|
||||
mod opt_args_and_ret;
|
||||
mod simple_fn;
|
||||
mod simple_struct;
|
3
crates/typescript-tests/src/memory.ts
Normal file
3
crates/typescript-tests/src/memory.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import * as wasm from '../pkg/typescript_tests_bg';
|
||||
|
||||
const memory: WebAssembly.Memory = wasm.memory;
|
6
crates/typescript-tests/src/opt_args_and_ret.rs
Normal file
6
crates/typescript-tests/src/opt_args_and_ret.rs
Normal file
@ -0,0 +1,6 @@
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn opt_fn(_a: Option<i32>) -> Option<i32> {
|
||||
None
|
||||
}
|
3
crates/typescript-tests/src/opt_args_and_ret.ts
Normal file
3
crates/typescript-tests/src/opt_args_and_ret.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import * as wbg from '../pkg/typescript_tests';
|
||||
|
||||
const opt_fn: (a: number | undefined) => number | undefined = wbg.opt_fn;
|
4
crates/typescript-tests/src/simple_fn.rs
Normal file
4
crates/typescript-tests/src/simple_fn.rs
Normal file
@ -0,0 +1,4 @@
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn greet(_: &str) {}
|
5
crates/typescript-tests/src/simple_fn.ts
Normal file
5
crates/typescript-tests/src/simple_fn.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import * as wbg from '../pkg/typescript_tests';
|
||||
import * as wasm from '../pkg/typescript_tests_bg';
|
||||
|
||||
const wbg_greet: (a: string) => void = wbg.greet;
|
||||
const wasm_greet: (a: number, b: number) => void = wasm.greet;
|
17
crates/typescript-tests/src/simple_struct.rs
Normal file
17
crates/typescript-tests/src/simple_struct.rs
Normal file
@ -0,0 +1,17 @@
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub struct A {
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
impl A {
|
||||
#[wasm_bindgen(constructor)]
|
||||
pub fn new() -> A {
|
||||
A {}
|
||||
}
|
||||
|
||||
pub fn other() {}
|
||||
|
||||
pub fn foo(&self) {}
|
||||
}
|
6
crates/typescript-tests/src/simple_struct.ts
Normal file
6
crates/typescript-tests/src/simple_struct.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import * as wbg from '../pkg/typescript_tests';
|
||||
|
||||
const a = new wbg.A();
|
||||
wbg.A.other();
|
||||
a.foo();
|
||||
a.free();
|
@ -9,6 +9,6 @@
|
||||
"baseUrl": "."
|
||||
},
|
||||
"include": [
|
||||
"index.ts"
|
||||
"src/*.ts"
|
||||
]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user