Skip to content

finding: 两个结构不兼容的 CalendarEvent 同名并存(@object-ui/types 授权型 vs @object-ui/plugin-calendar 运行时型),已造成一处文档示例不可编译 #5044

Description

@yinlianghui

发现于 #5010 的实施(plugin-calendar README)。Filed unassigned, not claiming.

现象

仓里有两个都叫 CalendarEvent 的公开导出类型,结构不兼容,分属两个包:

@object-ui/types(packages/types/src/complex.ts:136)@object-ui/plugin-calendar(packages/plugin-calendar/src/CalendarView.tsx:96)
语义授权型(JSON 元数据里写的事件)运行时型(CalendarViewProps['events'],React 组件收的事件)
idstringstring | number
startstring | DateDate
endstring | Date(必填)Date(可选)
description

CalendarViewSchema.events 要的是前者;CalendarView 组件收的是后者。两者互不可赋值(idstart 两处都冲突)。

已造成的实际损害

packages/plugin-calendar/README.md 的 "TypeScript Support" 一节把两者混用了,而且这个错误在 #5010 修掉导入路径之后依然存在 —— 因为它不是路径错、也不是虚构名,两个名字都是真导出。实测(#5010 实施中的编译探针,tsc 直接读源):

a-pathfix-only.ts(10,3): error TS2322: Type 'string' is not assignable to type 'Date'.
a-pathfix-only.ts(11,3): error TS2322: Type 'string' is not assignable to type 'Date'.
a-pathfix-only.ts(16,12): error TS2322: Type '…/plugin-calendar/src/CalendarView").CalendarEvent'
is not assignable to type '…/types/src/complex").CalendarEvent'.
Types of property 'id' are incompatible.
Type 'string | number' is not assignable to type 'string'.

#5010 的 PR 已把该 README 的示例改成两个授权型都从 @object-ui/types 取,并加了一段并列说明两者区别 —— 但那只治了这一处文档,同名本身没动(动它是契约变更,不在 #5010 卡面内)。

为什么单独立这一单

这正是「让 AI 写的元数据难以出错」那条轴上的典型坑:两个名字一样、语义一层是授权一层是运行时、IDE 自动导入会按字母序或最近使用随机挑一个,挑错了报的还是一个绕远的 TS2322(而不是「你导错包了」)。一个 AI 生成 calendar 元数据的场景里,这个坑会被反复踩。README 那处漂移能活到今天,一部分原因就是它「看起来对」。

顺带一记:plugin-calendar 已经有过一次同源的同名撞车并留了注释 —— src/index.tsx:23-30ObjectCalendarProps@objectstack/spec/ui 从 17.0.0 起占用(objectui#4650),当时的处理是改名 + 留 deprecated alias(ObjectCalendarComponentProps)。CalendarEvent 是同一类问题的下一个实例,可参照那次的处置形。

可能的方向(未选定,交维护者裁)

倾向 A:它在「长期架构」和「结构上防止出错」两条轴上都成立 —— 授权型保留契约正名,运行时型有了自解释的名字,且 deprecated alias 让现有 importer 继续编译,迁移成本可控;仓里已有 #4650 的先例可循。

分级

交 PM 分诊。挂 finding:今天没有用户运行时因此出错(#5010 已把唯一已知的受害文档修好),这一单是结构性隐患 + 契约命名决策,需要维护者裁方向再动手。

Metadata

Metadata

Assignees

No one assigned

    Labels

    domain:uiobjectui ui stream: fix lands on the published library or apps — objectui execution seatpm:queue

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions