Tuesday, October 10, 2017

Re: Exposing GWT components based on Elemental2 to TypeScript ?

On Tuesday, October 10, 2017 at 5:12:51 PM UTC+2, DavidN wrote:
I'm currently investigating how to expose a GWT based component (that uses JsInterop and Elemental2) to JavaScript and TypeScript.
The goal is that this component should be reusable in an Angular 4 application, but also in GWT applications.

I think you'll be delighted by J2Cl when available, and then use Clutz and/or Gents (https://github.com/angular/clutz) for TypeScript interop (see also https://github.com/material-components/material-components-web/issues/134 )

I'm finding it really hard to create a .d.ts file that is acceptable to Angular 4 (documentation and reality seem to clash).

I was wondering, am I the first to try this ? 
For now I gave up on the attempt to declare a proper .d.ts file and just declared the reference as any.
But somehow I think it would be nice if GWT had a linker that could actually output that TypeScript file automatically saving me from doing double work.

You could possibly use an annotation processor to do that (processing all jsinterop.annotations.* annotations)
I am using the sso-linker in GWT to get all my JsType classes exported and I just load the generated nocache.js file.
Is there a way to make sure that the contents of that file does not cache with other JS objects ? 
Can I somehow declare at compile time what I want to have exported ?

Yes, through -includeJsInteropExports and -excludeJsInteropExports patterns (added in 2.8.1)

There seems to be more in the output than what I actually need (I don't need an EntryPoint for example).

The entry point is required in GWT, but can be empty / no-op if you export JsInterop types.

You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment