docs/api.md documents props as `PropTypes`, and several entries are wrong
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 55/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- react, typescript
调研方向
从 docs/api.md 开始,将其中的四个 prop 表与 TypeScript 声明以及 LiveProvider 的 transformCode 调用位置进行核对。更新文档中的类型和默认值,修正 transformCode 的返回类型,并考虑 LiveEditor 的 Partial 接口面。已发布声明的变更需要一个 changeset。
由索引模型根据 Issue 内容生成。
描述
docs/api.md types every prop as PropTypes.string, PropTypes.bool, and so on — 16 rows
across four tables. There is no prop-types dependency in the repo. The props are
TypeScript, so the notation describes runtime validation that does not happen.
The file is already inconsistent with itself: the withLive() table types element as
React.Element, which is not a real type either (React.ReactElement).
Auditing the tables to convert them turned up three entries that are wrong on the facts, not
just the notation.
language default is documented as jsx
| language | `PropTypes.string` | ... (Default: `jsx`) |
LiveProvider defaults it to tsx:
language = "tsx",
LivePreview's Component is not a node
Documented as PropTypes.node. It is React.ElementType — a tag name or component, not
rendered output. node would be the wrong choice even in PropTypes terms (elementType).
transformCode's declared type contradicts its own call site
The docs say "accepts and returns the code to be transpiled", which matches what
LiveProvider actually does:
const transformResult = transformCode ? transformCode(newCode) : newCode;
const transformedCode = await Promise.resolve(transformResult);
if (typeof transformedCode !== "string") {
throw new Error("Code failed to transform");
}
The type says the return value is discarded:
transformCode?(code: string): void;
Here the docs are right and the source is wrong. TypeScript permits returning a value where
void is expected, so callers are not broken — but anyone reading the declarations sees a
mutator. Should be string | Promise<string>.
Order
- Fix
transformCode's return type. Separate from the docs work: it ships in the published
declarations and needs a changeset. - Convert the four tables to TypeScript types, correcting
language,Component, and
elementalong the way. - While in there,
LiveEditortakesPartial<EditorProps>, so the three documented props
are not its whole surface.
- 主要语言
- TypeScript
- 星标
- 4.6k
- 派生
- 260
- 平均合并
- 6 天 18 小时
- 30 天内合并 PR
- 1
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
FormidableLabs/react-live 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 48/100
FormidableLabs/react-live#417 ·
-
bug
难度 3/5 1-2 天 新手友好度 68/100
FormidableLabs/react-live#415 ·
-
bug
难度 3/5 1-2 天 新手友好度 52/100
FormidableLabs/react-live#413 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
FormidableLabs/react-live#411 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
FormidableLabs/react-live#410 · 1 条评论 ·
查看 FormidableLabs/react-live 的全部 Issue
相似的 Issue
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
-
Crush 未关闭
难度 1/5 1 小时以内 新手友好度 85/100
catppuccin/catppuccin#3125 ·
-
难度 1/5 1 小时以内 新手友好度 90/100
ElementsProject/cln-application#167 · 1 条评论 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 75/100
Quantco/pnpm-licenses#17 ·
-
难度 2/5 1-3 小时 新手友好度 75/100