zschuessler / DeltaE

CIE color difference formulas in JavaScript
http://zschuessler.github.io/DeltaE
The Unlicense
260 stars 25 forks source link

Add TypeScript definitions #7

Open jemgold opened 6 years ago

jemgold commented 6 years ago

Thanks for a great library! I had to add this file to get things moving in a TypeScript project; hope it's helpful if I share them :)

zschuessler commented 6 years ago

Thanks for the PR!

I'm familiar with the concept of TS, but not its implementation. How might I go about testing this implementation you've created? I'd like to set something up on a CodePen or similar so I can verify completeness before merging.

Cheers!

serprex commented 5 years ago

LGTM

Note: there's nothing really to test here. What's implemented here are only type definitions. A test would be to implement unit tests in typescript & require tests also pass typechecking when being transpiled

lsalazarm99 commented 4 years ago

@jongold Maybe instead of an interface for "Lab", you could use a type?

export type Lab = {
  L: number;
  A: number;
  B: number;
}

Declaring an interface may conflict with interfaces of similar names in the file where it is used. And types give you code completion too.

https://www.typescriptlang.org/docs/handbook/advanced-types.html#interfaces-vs-type-aliases

jemgold commented 4 years ago

@lsalazarm99 whoa, thanks! that clarifies a lot; always been confused about the difference between the two. I don't have time to make the change right now but feel free to PR!