Lit quick-start examples pass one type argument to a controller that requires twelve

未关闭 适合新手
#2,486 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
88/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
documentation

调研方向

从 docs/framework/lit/quick-start.md 中第 16 行附近的两个示例开始,并将它们与 packages/lit-form/src/tanstack-form-controller.ts 第 226 行 controller 上的十二个泛型参数进行比较。通过用 TypeScript strict mode 编译 starter 片段来复现;完成意味着两个 Lit quick-start 示例都通过类型检查,可能是通过去掉单个 <Employee> 参数并改为给 defaultValues 标注类型。检查完整示例的 FieldApi<Employee, 'firstName'> 注解是否一致。

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

描述

Hullo folks,

I’m doing some research for Tessl Code Review and ran it against your repo. It flagged a potential issue, and I figured it made sense to share it with you:

Describe the bug

The Lit quick-start still constructs new TanStackFormController<Employee>(this, ...), but the current controller has twelve required generic parameters. Copying that starter into a TypeScript Lit component produces TS2558.

This surfaced in a retrospective review of merged PR #2252. The same mismatch remains at 7a213d2: both quick-start examples supply one argument, while the class declaration supplies no defaults for the remaining parameters.

Minimal reproduction
import { LitElement } from 'lit';
import { TanStackFormController } from '@tanstack/lit-form';

interface Employee {
  firstName: string;
  lastName: string;
  employed: boolean;
  jobTitle: string;
}

export class TestForm extends LitElement {
  form = new TanStackFormController<Employee>(this, {
    defaultValues: {
      firstName: '', lastName: '', employed: false, jobTitle: '',
    },
  });
}

Codex ran TypeScript 5.8.3 with --strict --noEmit against the actual controller source from this checkout, resolving form-core 1.33.5, lit-store 0.13.2 and Lit 3.3.1. The only diagnostic was:

error TS2558: Expected 12 type arguments, but got 1.

The public documentation above is the source example for reproducing this.

Expected behavior / workaround

The introductory example should type-check with the current controller. Omitting <Employee> and typing defaultValues as Employee lets the controller infer its generics; that control compiled without diagnostics in the same environment.

The complete example also explicitly annotates FieldApi<Employee, 'firstName'>, so reviewing its generic annotations together would help keep the page consistent.

Environment

Current checkout 7a213d2 (lit-form package version 1.25.5), TypeScript 5.8.3, macOS 27.2. This verifies the compile-time starter issue; it does not claim a rendered Lit application test.

Full transparency: I work at Tessl, and we've spotted that using Tessl Code Review - using repository-level context and specific review lenses that improve over time through feedback. That’s how this finding surfaced.

We’re just getting started and want to offer the tool free to open-source projects. If this is useful, happy to give you access.

Bap

主要语言
TypeScript
星标
6.8k
派生
717
平均合并
5 天 22 小时
30 天内合并 PR
14

环境准备

从这里开始

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

TanStack/form 的其他 Issue

查看 TanStack/form 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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