Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(types): declare disablePrerender on StandardProps#19411

Open
xiangnuans wants to merge 1 commit into
NervJS:mainfrom
xiangnuans:fix/types-disable-prerender-19029
Open

fix(types): declare disablePrerender on StandardProps#19411
xiangnuans wants to merge 1 commit into
NervJS:mainfrom
xiangnuans:fix/types-disable-prerender-19029

Conversation

@xiangnuans

@xiangnuans xiangnuans commented Jul 2, 2026

Copy link
Copy Markdown

这个 PR 做了什么? (简要描述所做更改)

为公共组件属性类型 StandardProps 补充 disablePrerender?: boolean 声明。

预渲染运行时 (packages/taro-webpack5-runner/src/prerender/prerender.ts) 会读取元素上的 disablePrerender 属性来跳过该节点的预渲染,但该属性从未在 StandardProps 上声明,导致在任意组件上使用(如 <View disablePrerender />)时报 TS 错误:

不能将类型“{ ...; disablePrerender: true; ... }”分配给类型“IntrinsicAttributes & ViewProps”。
类型“IntrinsicAttributes & ViewProps”上不存在属性“disablePrerender”。

由于该属性作用于任意元素,故加在所有组件共享的基类型 StandardProps 上,与运行时行为一致。

这个 PR 是什么类型? (至少选择一个)

  • 错误修复 (Bugfix) issue: fix #
  • 新功能 (Feature)
  • 代码重构 (Refactor)
  • TypeScript 类型定义修改 (Types) issue: fix 属性disablePrerender 没定义 #19029
  • 文档修改 (Docs)
  • 代码风格更新 (Code style update)
  • 构建优化 (Chore)
  • 其他,请描述 (Other, please describe):

这个 PR 涉及以下平台:

  • 所有平台

Fixes #19029

Summary by CodeRabbit

  • 新功能
    • StandardProps 新增可选属性 disablePrerender,可用于在预渲染过程中跳过当前节点。

The prerender runtime reads `disablePrerender` off element props
(packages/taro-webpack5-runner/src/prerender/prerender.ts), but the type
was never declared on `StandardProps`, so setting it on any component
(e.g. `<View disablePrerender />`) raised a TS error:

    Property 'disablePrerender' does not exist on type
    'IntrinsicAttributes & ViewProps'.

Add it as an optional boolean on `StandardProps` (the base props shared by
all components), matching the runtime that reads it off any element.

Fixes NervJS#19029
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fedd376b-5bc7-404e-9af6-5c0462776f1f

📥 Commits

Reviewing files that changed from the base of the PR and between 0db37ec and 162e22f.

📒 Files selected for processing (1)
  • packages/taro-components/types/common.d.ts

Walkthrough

StandardProps 接口中新增了可选属性 disablePrerender?: boolean,并附加了说明该属性用于在预渲染过程中跳过当前节点的文档注释。

Changes

类型定义补充

Layer / File(s) Summary
StandardProps 新增 disablePrerender 属性
packages/taro-components/types/common.d.ts
StandardProps 接口中新增 disablePrerender?: boolean 可选属性,并附带跳过预渲染的说明注释。

Estimated code review effort: 1 (Trivial) | ~2 minutes

Poem

一行代码轻轻添,
类型缺口终得填。
预渲染前可跳过,
兔子蹦跳把测通完。🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了在 StandardProps 中声明 disablePrerender 的类型修复。
Linked Issues check ✅ Passed 代码仅为 StandardProps 增加了 disablePrerender?: boolean,符合 #19029 对 TypeScript 定义的要求。
Out of Scope Changes check ✅ Passed 变更范围集中在目标类型声明和注释,没有明显无关修改。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This was referenced Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

属性disablePrerender 没定义

1 participant