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

Generating Flow types #180

Open
jamiebuilds opened this issue Apr 30, 2018 · 2 comments
Open

Generating Flow types #180

jamiebuilds opened this issue Apr 30, 2018 · 2 comments

Comments

@jamiebuilds
Copy link
Member

Moving from https://github.com/ashleygwilliams/wasm-pack/issues/114#issuecomment-385122076

Flow's type def format is very similar to TypeScript's, it would be awesome if wasm-bindgen generated types for both.

I've actually implemented a type def printer for both at the same time in the past (only in JavaScript), it's not hard.

This is (basically) how I did it:

function push(ts, flow = ts) {
  tsDef.push(ts);
  flowDef.push(flow);
}

function printDeclareFunction(node) {
  push('function ', 'declare function '); // << different in Flow/TS, everything else is the same
  printIdentifier(node.name);
  push('(');
  node.args.forEach((arg, index) => {
    printArgument(arg);
    if (index < args.length - 1) push(', ');
  });
  push('): ');
  printType(node.returnType);
}
@alexcrichton
Copy link
Contributor

Seems reasonable to me! I'd be down for a PR to add such a flag

@ashleygwilliams
Copy link
Member

hrm i'm curious about doing this is bindgen and not in wasm-pack, it did seem like there was a very simple solution for doing it in wasm-pack. either way i want to make sure that we are clear on what the default behavior is and that i can make sure to support the correct flags so that this feature is exposed in wasm-pack, assuming we don't implement it there

mstange added a commit to mstange/perf.html that referenced this issue Aug 19, 2018
This also adds our first wasm module and updates the configuration so
that that's possible.
I've used wasm-pack to publish a gecko-profiler-demangle module to npm
instead of copying the generated code into this repository. I'm not sure
if that was a good or a bad idea; I mostly did it so that our Flow and
ESLint rules wouldn't be applied to the wasm-bindgen generated code.

I've also needed to autogenerate a flow libdef for this module.
wasm-bindgen doesn't create those automatically yet:
rustwasm/wasm-bindgen#180

I could have created one manually and included it in the published
package, but I don't know if wasm-pack would have included my additional
files in the published package (via `wasm-pack publish`).
mstange added a commit to mstange/perf.html that referenced this issue Aug 22, 2018
This also adds our first wasm module and updates the configuration so
that that's possible.
I've used wasm-pack to publish a gecko-profiler-demangle module to npm
instead of copying the generated code into this repository. I'm not sure
if that was a good or a bad idea; I mostly did it so that our Flow and
ESLint rules wouldn't be applied to the wasm-bindgen generated code.

I've also needed to autogenerate a flow libdef for this module.
wasm-bindgen doesn't create those automatically yet:
rustwasm/wasm-bindgen#180

I could have created one manually and included it in the published
package, but I don't know if wasm-pack would have included my additional
files in the published package (via `wasm-pack publish`).
mstange added a commit to mstange/perf.html that referenced this issue Aug 23, 2018
This also adds our first wasm module and updates the configuration so
that that's possible.
I've used wasm-pack to publish a gecko-profiler-demangle module to npm
instead of copying the generated code into this repository. I'm not sure
if that was a good or a bad idea; I mostly did it so that our Flow and
ESLint rules wouldn't be applied to the wasm-bindgen generated code.

I've also needed to autogenerate a flow libdef for this module.
wasm-bindgen doesn't create those automatically yet:
rustwasm/wasm-bindgen#180

I could have created one manually and included it in the published
package, but I don't know if wasm-pack would have included my additional
files in the published package (via `wasm-pack publish`).
mstange added a commit to mstange/perf.html that referenced this issue Sep 7, 2018
This also adds our first wasm module and updates the configuration so
that that's possible.
I've used wasm-pack to publish a gecko-profiler-demangle module to npm
instead of copying the generated code into this repository. I'm not sure
if that was a good or a bad idea; I mostly did it so that our Flow and
ESLint rules wouldn't be applied to the wasm-bindgen generated code.

I've also needed to autogenerate a flow libdef for this module.
wasm-bindgen doesn't create those automatically yet:
rustwasm/wasm-bindgen#180

I could have created one manually and included it in the published
package, but I don't know if wasm-pack would have included my additional
files in the published package (via `wasm-pack publish`).
mstange added a commit to mstange/perf.html that referenced this issue Sep 7, 2018
This also adds our first wasm module and updates the configuration so
that that's possible.
I've used wasm-pack to publish a gecko-profiler-demangle module to npm
instead of copying the generated code into this repository. I'm not sure
if that was a good or a bad idea; I mostly did it so that our Flow and
ESLint rules wouldn't be applied to the wasm-bindgen generated code.

I've also needed to autogenerate a flow libdef for this module.
wasm-bindgen doesn't create those automatically yet:
rustwasm/wasm-bindgen#180

I could have created one manually and included it in the published
package, but I don't know if wasm-pack would have included my additional
files in the published package (via `wasm-pack publish`).
mstange added a commit to mstange/perf.html that referenced this issue Sep 7, 2018
This also adds our first wasm module and updates the configuration so
that that's possible.
I've used wasm-pack to publish a gecko-profiler-demangle module to npm
instead of copying the generated code into this repository. I'm not sure
if that was a good or a bad idea; I mostly did it so that our Flow and
ESLint rules wouldn't be applied to the wasm-bindgen generated code.

I've also needed to autogenerate a flow libdef for this module.
wasm-bindgen doesn't create those automatically yet:
rustwasm/wasm-bindgen#180

I could have created one manually and included it in the published
package, but I don't know if wasm-pack would have included my additional
files in the published package (via `wasm-pack publish`).
mstange added a commit to mstange/perf.html that referenced this issue Sep 19, 2018
This also adds our first wasm module and updates the configuration so
that that's possible.
I've used wasm-pack to publish a gecko-profiler-demangle module to npm
instead of copying the generated code into this repository. I'm not sure
if that was a good or a bad idea; I mostly did it so that our Flow and
ESLint rules wouldn't be applied to the wasm-bindgen generated code.

I've also needed to autogenerate a flow libdef for this module.
wasm-bindgen doesn't create those automatically yet:
rustwasm/wasm-bindgen#180

I could have created one manually and included it in the published
package, but I don't know if wasm-pack would have included my additional
files in the published package (via `wasm-pack publish`).
mstange added a commit to firefox-devtools/profiler that referenced this issue Sep 19, 2018
This also adds our first wasm module and updates the configuration so
that that's possible.
I've used wasm-pack to publish a gecko-profiler-demangle module to npm
instead of copying the generated code into this repository. I'm not sure
if that was a good or a bad idea; I mostly did it so that our Flow and
ESLint rules wouldn't be applied to the wasm-bindgen generated code.

I've also needed to autogenerate a flow libdef for this module.
wasm-bindgen doesn't create those automatically yet:
rustwasm/wasm-bindgen#180

I could have created one manually and included it in the published
package, but I don't know if wasm-pack would have included my additional
files in the published package (via `wasm-pack publish`).
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

No branches or pull requests

3 participants