Skip to content

Long typescript_type leads to compile error in debug mode #2846

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

Closed
anlumo opened this issue Apr 1, 2022 · 0 comments · Fixed by #3162
Closed

Long typescript_type leads to compile error in debug mode #2846

anlumo opened this issue Apr 1, 2022 · 0 comments · Fixed by #3162
Labels

Comments

@anlumo
Copy link

anlumo commented Apr 1, 2022

Describe the Bug

When compiling in debug mode, having a long typescript_type annotation for a custom type leads to a compiler error. Release mode works fine.

Steps to Reproduce

Example code:

use wasm_bindgen::{prelude::*, JsCast};

#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(typescript_type = "{                                                         }")]
    pub type Foo;
}

#[wasm_bindgen]
pub fn foo() -> Foo {
    JsValue::from_f64(0.0).unchecked_into()
}

Build with:

wasm-pack build --debug --target web

Expected Behavior

Finished dev [unoptimized + debuginfo] target(s) in 0.34s
...
[INFO]: :-) Your wasm pkg is ready to publish at ...

Actual Behavior

    Finished dev [unoptimized + debuginfo] target(s) in 0.38s
[WARN]: :-) origin crate has no README
thread 'main' panicked at 'index out of bounds: the len is 256 but the index is 1073741823', [...]/wasm-bindgen-wasm-interpreter-0.2.79/src/lib.rs:307:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: Running the wasm-bindgen CLI

Additional Context

If you remove a single space from the typescript type definition, it works. There seems to be a maximum length allowed there, which seems to be around 58 characters (in my own project, the limit seems to be 54 characters for some reason). The content doesn't appear to matter.

Release builds work fine, this only fails in debug builds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant