Open
Description
Motivation
The current implementation of #[wasm_bindgen(typescript_custom_section)]
requires TypeScript code to be embedded directly as a string within the Rust source code. For example:
#[wasm_bindgen(typescript_custom_section)]
const TS_APPEND_CONTENT: &'static str = r#"
export type Coords = { "latitude": number, "longitude": number };
"#;
The motivation for this feature is to improve the developer experience by allowing TypeScript code to be written in separate files and included using include_str!
. This would enable better syntax highlighting, improve code organization, and make TypeScript definitions easier to maintain.
Proposed Solution
The proposed feature is to enhance #[wasm_bindgen(typescript_custom_section)]
so it can accept a string generated by include_str!
from a separate file. This would allow developers to write TypeScript definitions in dedicated .ts files and include them in the Rust code at compile time.
#[wasm_bindgen(typescript_custom_section)]
const TS_APPEND_CONTENT: &'static str = include_str!("coords.ts");