bgrins / TinyColor

Fast, small color manipulation and conversion for JavaScript
https://bgrins.github.io/TinyColor/
MIT License
5.08k stars 438 forks source link

Add TypeScript typings file for inclusion in TypeScript projects #104

Open NZSmartie opened 9 years ago

NZSmartie commented 9 years ago

Created a typings file based on the exposed functions defined in README.md

The functions are not annotated with JSDoc yet, this was just enough to compile and run in a RequireJS environment

bgrins commented 9 years ago

Hi @NZSmartie, thanks for the PR. What's the process for keeping these up to date? Would it be possible to auto generate this file if we had JSDoc annotations in the code?

NZSmartie commented 9 years ago

Generating a TypeScript .d.ts file from javascript isn't really possible, jQuery for example is all hand crafted.

However, if tinycolor was written in TypeScript and compiled down to .js, a --declarations parameter can be passed to tsc to produce a .d.ts file along side the .js file

NZSmartie commented 9 years ago

Overlooked how some functions were implemented in the tinycolor namespace, so moved functions to the declare ... var tinycolor object.

I'm still testing features on it and fixing mistakes as I go

SidIcarus commented 3 years ago

@bgrins, @NZSmartie A typings file, d.ts, can now be generated from javascript files via JSDocs via a tsconfig given the configurations of

{
  allowJs: true,
  declarations: true,
}

I think

braebo commented 1 year ago

Types are imperative for Javascript projects too. If there are no types shipped with this library, they should at least be published to Definitely Typed.

Ultimately though, this library should be converted to typescript ASAP.