`@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 个 reaction 已指派 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 分钟
30 天内合并 PR
486

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Effect-TS/effect 的其他 Issue

查看 Effect-TS/effect 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。