microsoft / TypeScriptSamples

Community Driven Samples for TypeScript
3.19k stars 1.79k forks source link

Polymer 2.0 web component example #120

Open gertcuykens opened 7 years ago

gertcuykens commented 7 years ago

https://github.com/gertcuykens/hello-world https://github.com/gertcuykens/decorators

I am doing my very best to put the bits and pieces together to present a Polymer 2.0 typescript example. Can you take a look please?

I have many typescript errors I am not sure about.

The polymer team is working on a better typescript experience for custom elements I think the TypeScript team should be involved too in this.

https://github.com/Polymer/polymer/pull/3954/files https://github.com/Microsoft/TSJS-lib-generator/pull/150 https://github.com/Microsoft/TSJS-lib-generator/pull/151

https://github.com/Polymer/docs/issues/1768

DanielRosenwasser commented 7 years ago

Hey @gertcuykens we're definitely up for taking a Polymer sample. We recently did some work to ensure custom elements could be created (which you can check out in our nightlies).

That said, I am not a Polymer expert, so you'll have to fill in some of the blanks for me. 😄

gertcuykens commented 7 years ago

Thanks,

tmp is the polymer team trying to figure out typings and is the most important part you should take a very good look at and collaborate with the polymer team. My knowledge is way too small to make sure the polymer team is doing it correctly.

Everything else is not so important right now and is just the way polymer represent their elements into a catalog https://elements.polymer-project.org basicly index.html is just a fancy way to document elements but is still work in progress for the new polymer 2.x and doesn't work yet :)

gertcuykens commented 7 years ago

The tmp files are copies from https://github.com/Polymer/polymer/tree/2.0-typescript

Please collaborate with the polymer team directly if you notice errors, i am just a hello world messenger :)

https://github.com/Polymer/polymer/pull/3954/files

DanielRosenwasser commented 7 years ago

I think we'll have to wait for https://github.com/Polymer/polymer/pull/3954 before we pull in samples to understand how they should be consumed.

gertcuykens commented 7 years ago

Yep I agree but please verify if there defenitions are done the right way. For exampe when I look at it in vscode i get

image

I can't judge if does errors are bad or not or if they prevent a better typing experience for the end user. Just hoping that a typescript expert from Microsoft has also reviewed it just to be safe before it is being injected in the offical polymer branch.

gertcuykens commented 7 years ago

I split the examples into two repositories because decorators are killing me to make a simple example work.

So this one is ok https://github.com/gertcuykens/hello-world and only needs a few more extra typings, but that I can probably figure out myself.

Decorators on the other hand are a disaster for me to setup correctly https://github.com/gertcuykens/decorators I am trying for days now to make this work, asked stackoverflow and any developer I could find to help me on this.

http://stackoverflow.com/questions/39926208/polymer-2-x-typescript-decorators-example

gertcuykens commented 7 years ago

Finally i figured decorators out... now the thing left is to understand umd vs polymer imd

https://github.com/PolymerLabs/IMD