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

add typescript definitions #231

Closed

Conversation

blushingpenguin
Copy link
Contributor

This adds typescript definition files (.d.ts) which allow fluent-react to be used from typescript easily

@friktor
Copy link

friktor commented Jul 19, 2018

IMHO it's extremely necessary to add support for typescript in fluent, please accept this PR, or add @types/fluent-* packages.
@stasm what do you think about this?

@stasm
Copy link
Contributor

stasm commented Aug 9, 2018

@blushingpenguin Sorry I haven't looked at this earlier. Is there some way to make sure type definitions stay up to date as we continue making changes to fluent.js? E.g. is some kind of CI testing possible?

@demurgos
Copy link

@stasm
To keep the definitions up-to-date, the best is to generate them from source: rename the source files from .js to .ts and use the Typescript compiler to generate both the .d.ts and .js files.

Another solution would be to just use Typescript for the test files and use the manually written definitions.

Overall, I agree that type definitions are very valuable, especially for consumers: they improve code completion and enable static checks.

If you're interested, I could try to send a minimal PR to convert the project to TS: do not change the code, just add the compiler.

@stasm
Copy link
Contributor

stasm commented Dec 19, 2018

To keep the definitions up-to-date, the best is to generate them from source: rename the source files from .js to .ts and use the Typescript compiler to generate both the .d.ts and .js files.

I'd describe myself as cautious when it comes to converting fluent to TypeScript :) I'm not opposed to it per se, but sticking to vanilla JS gives us a direct control over what the source code looks like. It also makes it easy to land fluent code in mozilla-central, which continues to be a very important driver behind the project :)

Another solution would be to just use Typescript for the test files and use the manually written definitions.

I like this idea a lot. The API surface is small enough that it might just work.

If you're interested, I could try to send a minimal PR to convert the project to TS: do not change the code, just add the compiler.

I'm sorry for not replying earlier. I'm very interested in doing something to help TypeScript users use Fluent. I also have more time to tend to this project, now that Fluent Syntax 0.8 has been released.

If you add the compiler, what will the consequences for the code in fluent/src be? Can we start with just fluent/test and try your second suggested approach first?

@demurgos
Copy link

demurgos commented May 7, 2019

Hi,
Thank you for your reply. Agreed, using Typescript only for the tests can be a good first step. I used this kind of setup for some of the Gulp plugins.

I'll try to send a PR building on top of this one.

@stasm stasm mentioned this pull request May 28, 2019
7 tasks
@blushingpenguin
Copy link
Contributor Author

These definitions are out of date and subsequently definitions were submitted to DefinitelyTyped (of which those definitions are now also out of date!). I have submitted some up to date definitions to DT so this PR isn't useful anymore.

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

Successfully merging this pull request may close these issues.

4 participants