`@effect/ui-native` (Effect-TS/ui): `Css.color` silently returns `undefined` for unparsed CSS colors (e.g. `oklch()` / `color-mix()`), violating its `Native.ProcessedColor` return type

Đang mở
#11,080 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@effect-bot đang làm issue này rồi.

Từ ngày 29/11/2026.

  • #646 của @effect-bot — đang mở

Đánh giá

Issue này chưa được đánh giá.

Mô tả

partially generated with help of my ai friend - neon 4.4

Hi effect team,
I was trying out this package and wanted to report some bugs encountered while porting a library to effect native

What version of Effect is running?
  • effect: 4.1.7
  • @effect/ui & @effect/ui-native: Effect-TS/ui main at 77391ee50ae3d3175d670facbf675e9a819ba6a6
  • react-native: 0.88.1
What steps can reproduce the bug?
  1. Clone the minimal reproduction repository:
    git clone https://github.com/cliffordfajardo/effectui-native-error-reproductions.git
    cd effectui-native-error-reproductions
    pnpm install
    pnpm test
    
  2. Call Css.color(...) or Css.boxShadow(...) with a valid CSS Color Level 4 string (such as oklch(...) or color-mix(...), commonly used in modern CSS design tokens):
import type * as Native from "@effect/ui-native/Native"
import * as Css from "@effect/ui-native/kit/Css"

const oklch: Native.ProcessedColor = Css.color("oklch(0.6204 0.195 253.83)")
const colorMix: Native.ProcessedColor = Css.color(
  "color-mix(in oklab, #000 50%, #fff)"
)
const shadows = Css.boxShadow("0 2px 8px oklch(0.6204 0.195 253.83)")
  1. Inspect the runtime values (see 02-css-color-returns-undefined-for-unparsed-colors/repro.test.ts).
What is the expected behavior?

Either:

  • Css.color (and Css.boxShadow) converts valid CSS Color Level 4 strings (or throws/fails explicitly on unsupported color strings) so the return value always satisfies Native.ProcessedColor, or
  • Css.color's return type accurately reflects React Native's ?ProcessedColorValue (Native.ProcessedColor | null | undefined) so callers are forced to handle unparsed colors instead of silently passing undefined into Fabric style objects.
What do you see instead?

packages/ui-native/src/kit/Css.ts:140-141 types Css.color as returning a non-nullable, non-undefined Native.ProcessedColor:

export const color: (color: Native.Color) => Native.ProcessedColor =
  processColor

where packages/ui-native/src/Native.ts:58-60 defines ProcessedColor as an opaque branded interface (excluding undefined and null), and packages/ui-native/src/kit/internal/processColor.ts:1 directly re-exports react-native/Libraries/StyleSheet/processColor.

In [email protected] (Libraries/StyleSheet/processColor.js:21-29), processColor has Flow return type ?ProcessedColorValue and returns undefined whenever normalizeColor(color) fails to parse the string (including CSS Color Level 4 formats like oklch(...) / color-mix(...) and malformed strings), or null when normalizedColor is not a number.

As a result:

  • Css.color("oklch(0.6204 0.195 253.83)") compiles with type Native.ProcessedColor (even under strict: true and exactOptionalPropertyTypes: true) yet evaluates to undefined at runtime without throwing.
  • Css.boxShadow("0 2px 8px oklch(0.6204 0.195 253.83)") silently returns [] because processBoxShadow.js:97-100 aborts the entire shadow array when processColor returns null/undefined.
Additional information

When porting custom components backed by CSS custom properties (which frequently use oklch(...) / color-mix(...) in modern design systems), this manifests as views and shadows silently disappearing at runtime with no TypeScript error or dev-mode warning.

Ngôn ngữ chính
TypeScript
Star
16.7k
Fork
808
Merge trung bình
21 giờ 22 phút
Pull request đã merge (30 ngày)
486

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Effect-TS/effect

Tất cả issue của Effect-TS/effect

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.