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

[Plugins] Typings #39

Open
janpio opened this issue Oct 2, 2018 · 18 comments
Open

[Plugins] Typings #39

janpio opened this issue Oct 2, 2018 · 18 comments
Labels

Comments

@janpio
Copy link
Member

janpio commented Oct 2, 2018

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?

@janpio janpio added discussion enhancement New feature or request labels Oct 2, 2018
@janpio
Copy link
Member Author

janpio commented Oct 2, 2018

(Ping @timbru31, who did a PR on the inappbrowser typings and is now considered a Typings expert by me)

@timbru31
Copy link
Member

timbru31 commented Oct 2, 2018

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 DefinitelyTyped/DefinitelyTyped#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 :)

@janpio
Copy link
Member Author

janpio commented Oct 2, 2018

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.

@timbru31
Copy link
Member

timbru31 commented Oct 2, 2018

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.

@janpio
Copy link
Member Author

janpio commented Oct 2, 2018

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?

@timbru31
Copy link
Member

timbru31 commented Oct 2, 2018

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.

@janpio
Copy link
Member Author

janpio commented Oct 2, 2018

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)

@timbru31
Copy link
Member

timbru31 commented Oct 4, 2018

That sounds like a plan!

@timbru31
Copy link
Member

timbru31 commented Jan 29, 2019

Making myself some nice list of active core plugins:

timbru31 added a commit to timbru31/cordova-plugin-vibration that referenced this issue Jan 30, 2019
* deletes removed features
* adds version number
* format code

This is part of apache/cordova#39
janpio pushed a commit to apache/cordova-plugin-vibration that referenced this issue Feb 13, 2019
* deletes removed features
* adds version number
* format code

This is part of apache/cordova#39

<!--
Please make sure the checklist boxes are all checked before submitting the PR. The checklist
is intended as a quick reference, for complete details please see our Contributor Guidelines:

http://cordova.apache.org/contribute/contribute_guidelines.html

Thanks!
-->

### Platforms affected

n/a - development with TypeScript

### What does this PR do?

updates typings as discussed in apache/cordova#39

### What testing has been done on this change?


### Checklist
- [ ] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database
- [ ] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
- [ ] Added automated test coverage as appropriate for this change.
timbru31 added a commit to timbru31/cordova-plugin-vibration that referenced this issue Feb 18, 2019
timbru31 added a commit to timbru31/cordova-plugin-statusbar that referenced this issue Feb 18, 2019
timbru31 added a commit to timbru31/cordova-plugin-device that referenced this issue Feb 18, 2019
janpio pushed a commit to apache/cordova-plugin-vibration that referenced this issue Feb 19, 2019
This is part of [apache/cordova#39](apache/cordova#39)

<!--
Please make sure the checklist boxes are all checked before submitting the PR. The checklist is intended as a quick reference, for complete details please see our Contributor Guidelines:

http://cordova.apache.org/contribute/contribute_guidelines.html

Thanks!
-->

### Platforms affected

n/a - development with TypeScript

### Motivation and Context

updates typings as discussed in [apache/cordova#39](apache/cordova#39)

### Description

Updates types to correctly use TSDoc format


### Testing

Manual testing via development in VSCode.


### Checklist

- [ ] I've run the tests to see all new and existing tests pass
- [ ] I added automated test coverage as appropriate for this change
- [ ] Commit is prefixed with `(platform)` if this change only applies to one platform (e.g. `(android)`)
- [ ] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct [keyword to close issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/))
- [ ] I've updated the documentation if necessary
timbru31 added a commit to timbru31/cordova-plugin-battery-status that referenced this issue Mar 2, 2019
janpio pushed a commit to apache/cordova-plugin-battery-status that referenced this issue Mar 4, 2019
this is part of apache/cordova#39

<!--
Please make sure the checklist boxes are all checked before submitting the PR. The checklist is intended as a quick reference, for complete details please see our Contributor Guidelines:

http://cordova.apache.org/contribute/contribute_guidelines.html

Thanks!
-->

### Platforms affected

n/a - development with TypeScript

### Motivation and Context
<!-- Why is this change required? What problem does it solve? -->
<!-- If it fixes an open issue, please link to the issue here. -->

updates typings as discussed in apache/cordova#39


### Description

Updates type definition header, simplifies event types and correctly format the TSDoc.

### Testing

Manual testing via development in VSCode.

### Checklist

- [ ] I've run the tests to see all new and existing tests pass
- [ ] I added automated test coverage as appropriate for this change
- [ ] Commit is prefixed with `(platform)` if this change only applies to one platform (e.g. `(android)`)
- [ ] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct [keyword to close issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/))
- [ ] I've updated the documentation if necessary
janpio pushed a commit to apache/cordova-plugin-statusbar that referenced this issue May 7, 2019
@janpio janpio added the plugins label May 10, 2019
@janpio
Copy link
Member Author

janpio commented Jul 11, 2019

As far as I am aware, all core plugins where it makes sense now have typings. Agree @timbru31?

@timbru31
Copy link
Member

While they might have typings they still need to be cleaned/updated/checked. See my list above. (I'm still not finished)

@janpio
Copy link
Member Author

janpio commented Jul 12, 2019

Okay awesome, we'll keep this open then.

@jcesarmobile
Copy link
Member

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 apache/cordova-plugin-file#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.

@distante
Copy link

distante commented Sep 22, 2019

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 ?

@jcesarmobile
Copy link
Member

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)

@distante
Copy link

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 :/

@jcesarmobile
Copy link
Member

No, you use the .npmignore file to not publish the typescript source code to npm.

@distante
Copy link

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 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants