`@effect/ui-native` (Effect-TS/ui): `Native.Host` is in `Command.FrameworkServices` (`R = never`) but missing from `@effect/ui-native/testing`

未关闭
#11,092 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
react-native, typescript
领域
mobile, testing

调研方向

Read packages/ui-native/src/testing/index.ts and the TestDevice.layer(...) implementation, then compare their provided services with Native.Host in packages/ui-native/src/Native.ts. Run the supplied Vitest reproduction to confirm the missing service. Done when native Play or Scene tests provide a usable Native.Host and the reproduction runs without the service-not-found error.

由索引模型根据 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 vitest run 06-native-host-missing-in-testing-layer
    
  2. Write a Native.component whose Command.make yields Native.Host (for example calling host.measure(node) or host.scrollTo(...) — the same pattern used internally by @effect/ui-native/kit/VirtualList):
const measureCmd = Command.make(
  Effect.fn(function*() {
    const refs = yield* Renderer.Refs
    const host = yield* Native.Host
    const node = refs.get("box") as NativeHost.NativeNode | undefined
    return node ? host.measure(node) : undefined
  })
)
  1. Run the component in a Vitest Play.make test using the documented native test layers Layer.merge(TestHost.layer(), TestDevice.layer("ios")) (see 06-native-host-missing-in-testing-layer/repro.test.ts).
What is the expected behavior?

Because Native.Host is declared in Command.FrameworkServices (packages/ui-native/src/Native.ts:1239-1243), TypeScript intentionally does not require tests to provide Native.Host manually (R = never). Accordingly, @effect/ui-native/testing (e.g. TestDevice.layer(...) or a dedicated TestNativeHost.layer(...)) should provide a working test Native.Host service so components using measure, scrollTo, focus, blur, etc. run cleanly in Play / Scene tests.

What do you see instead?

The test compiles with R = never, then fails at runtime as soon as the command executes:

Error: Service not found: @effect/ui-native/Native/Host

NativeApp.register provides Native.Host on real devices, but @effect/ui-native/testing (packages/ui-native/src/testing/index.ts) currently only exports TestDevice and provides no Native.Host implementation.

Additional information

Possible fix:

  • Provide a default/configurable Native.Host implementation from TestDevice.layer(...) (or export TestNativeHost.layer(...) from @effect/ui-native/testing) that records scrollTo / focus / blur / command calls and lets tests stub measure(node) rects.
主要语言
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 摘要。