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

Bug: 为指令定义特定类型的变长参数有非预期的行为 #1111

Closed
Tracked by #1085
BH4HPA opened this issue Jun 10, 2023 · 2 comments
Closed
Tracked by #1085

Bug: 为指令定义特定类型的变长参数有非预期的行为 #1111

BH4HPA opened this issue Jun 10, 2023 · 2 comments

Comments

@BH4HPA
Copy link

BH4HPA commented Jun 10, 2023

Describe the bug

注册一个指令,使用变长参数时,定义预期的类型,koishi只会转换第一个元素的类型,而保持剩下的不变(仍为 string),这会导致非预期的行为。

Steps to reproduce

  • 定义含有特定类型变长参数的指令
ctx
    .command('test [...rest:number]')
    .action(({ session }, ...rest) => {
      console.log(rest);
    });
  • 执行这个指令
  • 复现。

Expected behavior

变长参数禁止定义预期的类型,或者转换所有元素的类型。

Screenshots

d87f88689ac485ddcad71c585a5ac656.png

Versions

  • OS: Windows 11 (10.0.22621.1702)
  • Platform: onebot
  • Node version: 18.13.0
  • Koishi version: 4.13.2

Additional context

No response

@BH4HPA BH4HPA added the bug BUG label Jun 10, 2023
@shigma
Copy link
Member

shigma commented Jun 10, 2023

感谢反馈。我们尽快修复。

@shigma shigma closed this as completed in f793cdd Jun 10, 2023
@shigma
Copy link
Member

shigma commented Jun 10, 2023

已修复此问题,将在下个版本实装修复。

@shigma shigma mentioned this issue Jul 7, 2023
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants