TinyColor icon indicating copy to clipboard operation
TinyColor copied to clipboard

Add TypeScript typings file for inclusion in TypeScript projects

Open NZSmartie opened this issue 9 years ago • 5 comments

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

NZSmartie avatar Sep 17 '15 04:09 NZSmartie

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?

bgrins avatar Sep 17 '15 04:09 bgrins

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 avatar Sep 17 '15 05:09 NZSmartie

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

NZSmartie avatar Sep 17 '15 11:09 NZSmartie

@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

SidIcarus avatar Jun 22 '21 18:06 SidIcarus

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.

braebo avatar Jan 15 '23 18:01 braebo