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

Format .d.ts file #1221

Merged
merged 4 commits into from
Feb 1, 2019
Merged

Format .d.ts file #1221

merged 4 commits into from
Feb 1, 2019

Conversation

rhysd
Copy link
Contributor

@rhysd rhysd commented Feb 1, 2019

Type definition file is useful not only for TypeScript compiler but also for programmers to know the API. However, current .d.ts file generated by wasm-bindgen is not fully formatted.

This patch improves readability of generated .d.ts file by fixing some formats

  • Give each class member 2 spaces indentation
  • Remove unnecessary space before function name
  • Remove unnecessary blank lines
  • Give 2 space indentations to each enum variant

I applied my patched wasm-bindgen to my project. Here is the result.

Before applying this patch:

/* tslint:disable */
export enum Resolution {Low,Middle,High,}
export enum LandKind {Sea,Mountain,Forest,Plain,Town,Top,Highland,DeepSea,Path,}
export class Cell {
free(): void;
kind: number;
altitude: number;

 color_code(): string;

 rgb_color(): number | undefined;

 legend(): string;

}
export class Generator {
free(): void;

static  new(): Generator;

 gen_auto(arg0: number, arg1: number): Board;

 gen(arg0: number, arg1: number, arg2: number): Board;

}
export class Board {
free(): void;

 width(): number;

 height(): number;

 at(arg0: number, arg1: number): Cell;

 as_json(): string;

}

After applying this patch

/* tslint:disable */
export enum LandKind {
  Sea,
  Mountain,
  Forest,
  Plain,
  Town,
  Top,
  Highland,
  DeepSea,
  Path,
}
export enum Resolution {
  Low,
  Middle,
  High,
}
export class Board {
  free(): void;
  width(): number;
  height(): number;
  at(arg0: number, arg1: number): Cell;
  as_json(): string;
}
export class Cell {
  free(): void;
  kind: number;
  altitude: number;
  color_code(): string;
  rgb_color(): number | undefined;
  legend(): string;
}
export class Generator {
  free(): void;
  static new(): Generator;
  gen_auto(arg0: number, arg1: number): Board;
  gen(arg0: number, arg1: number, arg2: number): Board;
}

@rhysd
Copy link
Contributor Author

rhysd commented Feb 1, 2019

CI failure looks not related to this patch.

https://travis-ci.com/rustwasm/wasm-bindgen/jobs/174605805

error: test failed, to rerun pass '--test all'
The command "cargo test -p wasm-bindgen-gc" exited with 2.

@alexcrichton
Copy link
Contributor

Looks great to me, thanks! No need to worry about that error

@alexcrichton alexcrichton merged commit 2e80313 into rustwasm:master Feb 1, 2019
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