You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

构建Turborepo项目时遭遇奇怪的TypeScript类型错误

TurboRepo模板开发中TypeScript类型错误问题

我正在使用turborepo-template进行开发,之前一切正常,但突然TypeScript开始抛出奇怪的类型错误:

../../packages/fork-me/src/client/star-me/star-me.tsx:19:4
nextjs-example:build: Type error: Type 'string | number | true | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode>' is not assignable to type 'ReactNode'.
nextjs-example:build:   Type 'ReactElement<any, string | JSXElementConstructor<any>>' is not assignable to type 'ReactNode'.
nextjs-example:build:     Property 'children' is missing in type 'ReactElement<any, string | JSXElementConstructor<any>>' but required in type 'ReactPortal'.
nextjs-example:build:
nextjs-example:build:   17 |    return (
nextjs-example:build:   18 |            <button data-testid="star-me-h1" onClick={starMe} type="button" {...props}>
nextjs-example:build: > 19 |                    {children || "Star Me"}
nextjs-example:build:      |                    ^
nextjs-example:build:   20 |            </button>
nextjs-example:build:   21 |    );
nextjs-example:build:   22 | }

错误指向packages/fork-me/src/client/star-me/star-me.tsx文件。奇怪的是,单独打包这个包时没有任何错误,但构建示例项目时却会触发这个错误。

内容的提问来源于stack exchange,提问作者Mayank Kumar Chaudhari

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 10:32:10