`@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

オープン
#11,080 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@effect-bot がすでに取り組んでいます。

2026年11月29日 から。

  • #646 @effect-bot による — オープン

評価

この issue はまだ評価されていません。

説明

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.

主要言語
TypeScript
スター
16.7k
フォーク
808
平均マージ
21時間 22分
マージ済み PR(30日)
486

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Effect-TS/effect のほかの issue

Effect-TS/effect の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。