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

Typescript type definitions for @lingui/core #351

Closed
tricoder42 opened this issue Oct 3, 2018 · 14 comments
Closed

Typescript type definitions for @lingui/core #351

tricoder42 opened this issue Oct 3, 2018 · 14 comments

Comments

@tricoder42
Copy link
Contributor

This is a HactoberFest issue! Read the contest details for more info.

Before you begin

  • Confirm that you're working on this issue so I can add 👩‍💻assigned label.
  • Use next branch as a base for your PR. This feature should be released in upcoming v3.
  • Read the contribution guide for info how to setup project, run tests and use development version of packages
  • Join us on gitter to get support

Description

Provide Typescript type definitions for @lingui/core

Core exports few types from i18n.js using Flow type checker. I recently learned that it's possible to publish Typescript declaration files. This would be great for Typescript users.

Task

Provide declaration file for i18n.js module and add it to package.json

Additional info

I have no experience with Typescript at all. Any suggestions about publishing or testing are welcome!

@danielkcz
Copy link
Contributor

I would love to get involved in this, but I am really busy lately.

Either way, I will chime in with an opinion. I've found this flowgen tools which should be able to generate flow types out of typescript. I think it's worth the try. It would mean to use TypeScript in the code and get flow out of it in a build step. I wouldn't worry too much about rewrite as on the base level it's pretty similar.

@tricoder42
Copy link
Contributor Author

I see. I would rather do it the other way round (e.g. flow-to-typescript) or manually for now. I don't have much spare time either. Learning Typescript and rewrite/maintain the repo might be too much at the moment. Let's review this option next month when I should be more available.

@danielkcz
Copy link
Contributor

Sure, other way around can work too, I wasn't able to find that tool you have. If it works, it would probably easiest route instead of maintaining separate typescript files manually. If it can generate quality typings, why not use it for a whole repo, not just a core one?

Btw, TypeScript is not really that different from the Flow, at least syntactically speaking. I know it sounds bit scary, been there too. It looks like something completely different from what you know, perhaps it's not even JavaScript? :D Trust me, it's not like that and you would be surprised how smooth experience it is.

Doesn't matter, it was just my opinion. Since this is not a priority right now and we are both busy, perhaps someone else would be able to saddle this beast :)

@manjunatha-d
Copy link

I'll take a stab at this.

@tricoder42
Copy link
Contributor Author

@Kalabhairava Great! Thanks a lot! Just to be clear: only provide typings based on Flow types. Either manually or automated using conversion tool. Please don't rewrite the whole library to Typescript 🙈

@manjunatha-d
Copy link

manjunatha-d commented Oct 4, 2018

@tricoder42, I'm having trouble setting up the environment.

The step nvm install -s v8.11.4 --with-intl=full-icu is failing with

gyp:  --with-intl=full-icu not found (cwd: /home/manjunathad/.nvm/.cache/src/node-v8.11.4/files) while trying to load  --with-intl=full-icu
Error running GYP
nvm: install v8.11.4 failed!

Any leads on fixing that?

When I run yarn test on node v10.5.0, I see a bunch of failures.

Thanks!

@danielkcz
Copy link
Contributor

danielkcz commented Oct 5, 2018

@Kalabhairava Are you sure you can run NVM like this? I am on Windows, so I am not sure how that works. I guess you will have more luck filling an issue at NVM repo.

@tricoder42
Copy link
Contributor Author

@Kalabhairava What shell do you use? There's related issue in nvm repo: nvm-sh/nvm#1719

@tricoder42
Copy link
Contributor Author

Just leaving it here for futures reference mui/material-ui-pickers#674

@Shermayster
Copy link

@Kalabhairava are you started working on this? Maybe I can help you?

@manjunatha-d
Copy link

@Shermayster, my apologies 😞

I'm caught up with a lot of work since the last few weeks, so I wasn't able to take a look at this issue. Please remove the assigned label, so that others can pick it up if they want. If it is still open after a weeks, I can take it up.

My apologies again 😞

@chaselal
Copy link

chaselal commented Dec 6, 2018

The documentation suggests this work is already done.

f789af1#diff-4cf0ca2c328ede20791c3f181ed03586R11

`Jeow Li Huan <https://github.com/huan086>`_ wrote type definition for ``@lingui/core``

Am I missing something?

@LStAmour
Copy link

You can install types with npm install --save-dev @types/lingui__core or yarn add -D @types/lingui__core: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/lingui__core

Also npm install --save-dev @types/lingui__react or yarn add -D @types/lingui__react: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/lingui__react

And npm install --save-dev @types/lingui__macro or yarn add -D @types/lingui__macro: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/lingui__macro

Any issues with the types can be reported here: https://github.com/huan086/lingui-typings/issues?utf8=✓&q=is%3Aissue+

The PRs against the @types repo can be found at: https://github.com/DefinitelyTyped/DefinitelyTyped/pulls?q=is%3Apr+lingui+is%3Aclosed

A PR for this project to support TS extraction is at https://github.com/lingui/js-lingui/pull/228/files

@tricoder42
Copy link
Contributor Author

next branch was rewrite in typescript, so core and react packages include auto-generated definition files. Checkout #334 for info about pre-release.

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

No branches or pull requests

6 participants