Polymer / pwa-helpers

Small helper methods or mixins to help you build web apps.
BSD 3-Clause "New" or "Revised" License
439 stars 48 forks source link

Added type definitions #37

Closed eterna2 closed 5 years ago

eterna2 commented 5 years ago

Changes

Dabolus commented 5 years ago

Not sure if things have changed since then, but according to the comments in this PR, it seems like the team would like to keep the typings on DefinitelyTyped (i.e. @types) instead of inside this repo

keanulee commented 5 years ago

@Dabolus We are revisiting that decision due to our goal of making a TypeScript template of pwa-starter-kit (which requires its deps to have types, so we would have to maintain the types anyways). I made some yet-to-be-reviewed progress in the typescript branch (source in TS), but I'll take a look at this PR as well.

Dabolus commented 5 years ago

@keanulee happy to hear that! Having the typings maintained on DefinitelyTyped would slow up a lot the work of TypeScript developers, as new updates on pwa-helpers would require some days to be published on @types/pwa-helpers

Dabolus commented 5 years ago

Sooo some brainstorming:

Pros of having the source code as TS

Robustness Having a statically typed language helps spotting and avoiding some errors during development and compilation instead of during runtime, making the code base much more robust

Consistency Most of the other modern Polymer projects are written in TypeScript (lit-html, LitElement, the entire Polymer tools repo and PRPL server). Even Material Web Components are migrating to TypeScript. Having a TS code base would make this repo consistent with others

Cons

Overkill? TypeScript might be a bit overkill for such a simple code base. However, I don't think this could be considered a real con

Additional step The code needs a build step to be converted into JavaScript. However, this might even be considered a pro, since with a build step we would be able to do more transformations to the code if needed, such as converting the helpers into a browser-ready UMD version or into a CommonJS version. Also, if we let a prepublish hook do the work we don't even have to worry about this extra step


In conclusion, I see only pros in having the source code as TS. The only "con" is that we need to configure the build steps properly, but it shouldn't give too much hassle

eterna2 commented 5 years ago

I totally agree with @Dabolus on his analysis on having typescript source.