Skip to content

Commit e73fb35

Browse files
authored
Refactor color utilities and update type handling (#117)
- Removed unused type definitions related to CSS colors in color.ts. - Updated the Serializable type in types-utils.ts to replace CssColor with string for better type consistency. These changes streamline the color utility functions and enhance type safety across the codebase.
1 parent f1bee6b commit e73fb35

File tree

2 files changed

+1
-13
lines changed

2 files changed

+1
-13
lines changed

packages/lib/src/utils/color.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,3 @@ export const getColorPropertyNames = <T extends object>(target: T): Array<keyof
181181

182182
return colorNames as Array<keyof T & string>;
183183
};
184-
185-
// Extract color names directly from the object
186-
type CssColorName = keyof typeof cssColorNamesMap;
187-
188-
// Combine all valid CSS color types
189-
export type CssColor = CssColorName | `#${string}`
190-
191-
// // Utility to replace pc.Color with CssColor
192-
// export type WithCssColors<T> = {
193-
// [K in keyof T]: T[K] extends Color ? CssColor : T[K];
194-
// };

packages/lib/src/utils/types-utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Color } from "playcanvas";
44
import { Vec4 } from "playcanvas";
55
import { Quat } from "playcanvas";
66
import { Vec3 } from "playcanvas";
7-
import { CssColor } from "./color";
87

98
type BuiltInKeys =
109
| 'constructor' | 'prototype' | 'length' | 'name'
@@ -36,7 +35,7 @@ export type PublicProps<T> = {
3635

3736

3837
export type Serializable<T> = {
39-
[K in keyof T]: T[K] extends Color ? CssColor :
38+
[K in keyof T]: T[K] extends Color ? string :
4039
T[K] extends Vec2 ? [number, number] :
4140
T[K] extends Vec3 ? [number, number, number] :
4241
T[K] extends Vec4 ? [number, number, number, number] :

0 commit comments

Comments
 (0)