Skip to content
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

Fix missing semicolons at generated struct fields in .d.ts #1181

Merged
merged 1 commit into from
Jan 15, 2019

Conversation

rhysd
Copy link
Contributor

@rhysd rhysd commented Jan 15, 2019

I had Rust+Wasm tutorial (Thank you for nice tutorial BTW!) and found that generated TypeScript type definition was wrong.

Rust:

#[wasm_bindgen]
pub struct Universe {
    pub width: u32,
    pub height: u32,
    // ...
}

Generated .d.ts

export class Universe {
free(): void;
width: number
height: number

// ...
}

TypeScript class property requires semicolon at the end. https://www.typescriptlang.org/docs/handbook/classes.html

So I expected

export class Universe {
free(): void;
width: number;
height: number;

// ...
}

I fixed the issue by this PR.

I confirmed it fixes the issue by manually building wasm-bindgen cli and running it in my local project. But I did not add any test for this change because I could not find any tests for TypeScript .d.ts generation.

@alexcrichton alexcrichton merged commit d5b6c52 into rustwasm:master Jan 15, 2019
@alexcrichton
Copy link
Contributor

Oops, thanks for this!

@rhysd rhysd deleted the fix-dts-struct-fields branch January 16, 2019 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants