ondras / rot.js

ROguelike Toolkit in JavaScript. Cool dungeon-related stuff, interactive manual, documentation, tests!
https://ondras.github.io/rot.js/hp/
BSD 3-Clause "New" or "Revised" License
2.33k stars 254 forks source link

color.js type declarations should use Color more aggressively instead of number[] #154

Closed jaspercb closed 5 years ago

jaspercb commented 5 years ago

The declarations in lib/color.d.ts are insufficiently strong. An expression like ROT.Color.toRGB(ROT.Color.interpolate(color1, color2, 0.5)) is poorly typed because interpolate returns a number[], not the [number, number, number] taken by toRGB. From a quick overview of colors.js, I believe the type declarations could be updated without trouble, so I suggest that all (or at least most, barring unforeseen issues) instances of number[] in color.d.ts be replaced by the defined Color type. For example, function interpolate(color1: Color, color2: Color, factor?: number): number[]; should be function interpolate(color1: Color, color2: Color, factor?: number): Color;

ondras commented 5 years ago

@jaspercb shall be better now. Please confirm if the current version is okay for you.