Open janpio opened 6 years ago
(Ping @timbru31, who did a PR on the inappbrowser typings and is now considered a Typings expert by me)
IMHO:
Are those still needed?
If you plan to develop with TypeScript and don't use @ionic-native/x
they are very convenient for the development, but of course only when the are kept updated.
What is the simplest way to keep them up to date?
The "de facto" standard for typings removed the cordova ones, because some cordova-plugins provide them directly. (see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/22305)
The main goal should be: consistency. Either remove all typings from the cordova-plugins (repo) and maintain them via DefinitelyTyped (and the npm @types/
) packages or provide them via the cordova-plugin itself.
Both approaches are fine. Sometimes the plugin/project authors don't want or use TypeScript and don't provide the typings - in this case the community can add them via DefinitelyTyped. If you go for the second approach, you need of course someone in the Apache/Cordova org to maintain them :)
Hm, we (could that include you?) could certainly take care of the typings for Cordova Core Plugins that are hosted here in the Apache repository. It makes more sense to keep them close to the actual code, as it help keeping them up to date (and e.g. can be enforced on Pull Requests).
What are the processes to generate them? Any automation?
What about other plugins - would our decision somehow have consequences for them? There are lots more third party Cordova plugins than Core plugins.
Hm, we (could that include you?) could certainly take care of the typings for Cordova Core Plugins that are hosted here in the Apache repository. It makes more sense to keep them close to the actual code, as it help keeping them up to date (and e.g. can be enforced on Pull Requests).
Of course it's easier to enforce proper reviews or updates to existing typings when the typings are maintained here. DefinitelyTyped relies on volunteers (called maintainers) for each typing project, too. Only in case they do not review the PR for "their" package the DefinitelyTyped maintainers will do an express review (and if the CI passes merge the PR).
I'm happy to help with the typings but would appreciate it, if there would be more than person involved with the typings - otherwise a missing review could block an otherwise good PR.
What are the processes to generate them? Any automation?
There are some tools (see e.g. https://stackoverflow.com/a/12695001/1902598), but some manual work is required. If you develop in TypeScript and transpile to JavaScript you get the typings for free from TypeScript. (And personally I favor the manual work or just write TypeScript over JavaScript)
What about other plugins - would our decision somehow have consequences for them? There are lots more third party Cordova plugins than Core plugins.
No. Each plugin, which is a standalone npm package, needs to provide the typings themself or rely on e.g. DefinitelyTyped.
If e.g. the Apache org decides to maintain them this is not required or enforced for other plugins.
Ok, from a first look at https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types it seems cordova
is the only Apache Cordova related one left: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cordova Correct?
Which means, the others already have to be included in all our repos, or they just don't exist. Best way forward would be to confirm with the PMC that typings should stay in the Apache Cordova repos and will be considered for and included in future updates. Correct?
We will probably want to create a super simple TypeScript test project that uses all the Apache Cordova packages where one can test the definitions I guess? Is there a way to CI them?
Ok, from a first look at DefinitelyTyped/DefinitelyTyped:types@master it seems cordova is the only Apache Cordova related one left: DefinitelyTyped/DefinitelyTyped:types/cordova@master Correct?
Seems so, yes. I haven't spotted any core plugins that I'm aware of with a quick look.
Which means, the others already have to be included in all our repos, or they just don't exist. Best way forward would be to confirm with the PMC that typings should stay in the Apache Cordova repos and will be considered for and included in future updates. Correct?
Correct. Some might habe been migrated, some others deleted by the PR mentioned in my first comment. Correct about the PCM part I guess - I'm not that involved in Apache's project steering and management (yet).
We will probably want to create a super simple TypeScript test project that uses all the Apache Cordova packages where one can test the definitions I guess? Is there a way to CI them?
Would be a good idea. The DefinitelyTyped project uses a simple "it does compile" TravisCI job. This could be adapted.
The TypeScript compiler can be used in the CI, a linter (tslint) does exist, too.
Do you maybe want to check a handful of the active core plugins for up to date typings - I am pretty sure we can work on the "not involved in Apache" thing then ;) (No time pressure or anything, just if you have the time and motivation)
That sounds like a plan!
Making myself some nice list of active core plugins:
As far as I am aware, all core plugins where it makes sense now have typings. Agree @timbru31?
While they might have typings they still need to be cleaned/updated/checked. See my list above. (I'm still not finished)
Okay awesome, we'll keep this open then.
We should have them, and make sure we keep them up to date. At the beginning of 2017 it was discussed if we should keep our own types instead of using the DefinitelyTyped ones and everybody voted for yes, that's why all core plugins now have the types and they were removed from DefinitelyTyped.
Another good discussion would be if we should change them to use export as proposed on https://github.com/apache/cordova-plugin-file/pull/285 so people can use them like import x from 'cordova-plugin-xxx'
or if we prefer to keep them like they are. Not sure of the cons-pros of every approach, but people seems to like more the import approach.
When developing an cordova plugin with typescript does the source typescript gets shipped with the plugin? Or does one needs to have two repos one for the typescript other for the dist? (I mean regarding the cordova plugin add http://some-repo.git
?
You can do it as you wish, but ideally you should ship the definitions with your plugin so the user don’t have to install two packages. If developing the plugin with typescript you’ll ship the generated code, not the typescript code (other than the already mentioned definitions)
That means I need to have two repos don't I? One with the generated code that can be used to install the plugin and another for development. It seems overkill :/
No, you use the .npmignore file to not publish the typescript source code to npm.
Ahh I see, so if the user uses npm all is ok. And if he uses git then it is not important. Thank you @jcesarmobile !
Typings for TypeScript: Some plugins have them, some don't, some are kept updated, some are not. Are those still needed? What is the simplest way to keep them up to date? Do we want to support them or not?