Install packages:
build-essentiallibssl-devpkg-config
Initialize cargo project for wasm.
> cargo generate --git https://github.com/rustwasm/wasm-pack-template
Install wasm-pack.
> cargo install wasm-pack
Build for wasm.
> wasm-pack build --target web
Then js, d.ts and .wasm files are generated in pkg.
Copy pkg/* into Typescript project (src/lib/wasm, for this case).
import init, {greet} from "./lib/wasm";
(async () => {
await init();
greet();
})()
The point is to call init() before using greet.