Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

computed TypeScript error #1

Closed
5 of 7 tasks
Mi-liu opened this issue Jun 30, 2024 · 2 comments
Closed
5 of 7 tasks

computed TypeScript error #1

Mi-liu opened this issue Jun 30, 2024 · 2 comments

Comments

@Mi-liu
Copy link

Mi-liu commented Jun 30, 2024

Describe the bug

I am glad to be able to use this small tool, but I encountered some problems during use
image
image

type CustomFormchildrens = Array<Input>
interface CustomFormChildren<T extends string, V = any> {
  /** 组件类型 */
  type: T
  /** 初始化值 */
  initialValue?: V
  /** FormItem配置 */
  formItem: any
  /** 格式化数据 在调用 validate 方法通过后调用 */
  formatter?: (v?: V) => any
}

/** Form 展示组件 统一的类型  */
type CustomFormChildrenMixinType<T> = Partial<T> & {
  class?: string
}

/** 输入框 */
interface Input extends CustomFormChildren<'input', string> {}

Reproduction

1

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 Intel(R) Core(TM) i5-8300H CPU @ 2.30GHz
    Memory: 5.29 GB / 15.86 GB
  Binaries:
    Node: 21.6.2 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.21 - C:\Program Files\nodejs\yarn.CMD
    npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.4.0 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Edge: Chromium (125.0.2535.92)
    Internet Explorer: 11.0.19041.3636

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Contributions

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)
@antfu
Copy link
Owner

antfu commented Jun 30, 2024

Consider using $((): YouType => ({})) instead of generic?

@Mi-liu
Copy link
Author

Mi-liu commented Jun 30, 2024

考虑使用而不是通用?$((): YouType => ({}))

Thank you, the problem has been resolved based on your answer (^▽^)

@Mi-liu Mi-liu closed this as completed Jun 30, 2024
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

No branches or pull requests

2 participants