Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

High TypeScript checking cost from generated Zod 3 schemas

未关闭
#2,624 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
22/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
活跃
技术栈
nodejs, typescript
领域
performance

调研方向

Start with the reproduction: a one-line import of LazyValue and TestBackgroundLogger from braintrust, checked with yarn exec tsc --extendedDiagnostics under the given tsconfig, compared against an export {} baseline. The generated schemas live in js/src/generated_types.ts, which imports zod/v3. Done means a measured drop in type and instantiation counts while the public input and output types stay the same. The issue asks for that benchmark before any migration.

由索引模型根据 Issue 内容生成。

描述

Braintrust 3.37.2 adds substantial declaration-checking work from a single unused import.

Reproduction

Use Node.js 24.21.0 and an ESM project ("type": "module" in package.json). With Yarn, set nodeLinker: node-modules in .yarnrc.yml.

yarn add [email protected] [email protected]
yarn add -D [email protected] @types/[email protected] [email protected]

repro.ts:

import { LazyValue, TestBackgroundLogger } from "braintrust";

tsconfig.json:

{
  "compilerOptions": {
    "strict": true,
    "target": "ES2023",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "types": ["node"],
    "skipLibCheck": false,
    "noEmit": true
  },
  "files": ["repro.ts"]
}

Run yarn exec tsc --extendedDiagnostics. For the baseline, replace the import with export {};.

Results

All checks pass. Measured deterministic counts on TS7:

Case Types Instantiations
No Braintrust import 64,716 62,345
With Braintrust import 624,895 1,791,353

No SDK calls or credentials are required. The root and braintrust/node imports load the same declarations.

Possible fix

Generated schemas import zod/v3. Zod 4 redesigned its generics to reduce compiler instantiations.

Could these schemas migrate to Zod 4 and the public declarations be regenerated? That seems like the first approach to benchmark, while preserving precise public input and output types. We have not measured an actual schema migration yet.

主要语言
TypeScript
星标
29
派生
16
平均合并
1 天 22 小时
30 天内合并 PR
72

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

braintrustdata/braintrust-sdk-javascript 的其他 Issue

查看 braintrustdata/braintrust-sdk-javascript 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。