We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
napi-exported functions can have incorrect signatures.
https://github.com/naskya/napi-rs-sig-example
src ├── bar.rs ├── foo.rs └── lib.rs
/// bar.rs #[napi_derive::napi(object, js_name = "Bar")] pub struct Thing { pub id: u32, } /// foo.rs #[napi_derive::napi(object, js_name = "Foo")] pub struct Thing { pub name: String, } /// lib.rs pub mod bar; pub mod foo; #[napi_derive::napi] pub fn do_something(bar: bar::Thing) {}
doSomething should take Bar as an argument.
doSomething
Bar
export interface Bar { id: number } export interface Foo { name: string } export function doSomething(bar: Bar): void
doSomething takes Foo instead of Bar.
Foo
export interface Bar { id: number } export interface Foo { name: string } export function doSomething(bar: Foo): void
In this particular case, napi-rs generates the correct function if you swap pub mod foo; and pub mod bar; in lib.rs
pub mod foo;
pub mod bar;
lib.rs
/// lib.rs pub mod foo; pub mod bar; #[napi_derive::napi] pub fn do_something(bar: bar::Thing) {}
export interface Foo { name: string } export interface Bar { id: number } export function doSomething(bar: Bar): void
Give it a type alias.
/// lib.rs pub mod bar; pub mod foo; type Bar = bar::Thing; #[napi_derive::napi] pub fn do_something(bar: Bar) {}
The text was updated successfully, but these errors were encountered:
refactor (backend): port add-note-to-antenna to backend-rs
ccbd617
I hit this bug: napi-rs/napi-rs#2060
No branches or pull requests
Problem
napi-exported functions can have incorrect signatures.
Example
https://github.com/naskya/napi-rs-sig-example
Setup
Expected behavior
doSomething
should takeBar
as an argument.Actual behavior
doSomething
takesFoo
instead ofBar
.Workaround 1
In this particular case, napi-rs generates the correct function if you swap
pub mod foo;
andpub mod bar;
inlib.rs
Workaround 2
Give it a type alias.
The text was updated successfully, but these errors were encountered: