KScript 文档
ZH

错误代码

KS6014

以完整写法书写的类型。 .kscript 文件中的一个错误。这些都只有一种形式,而 kscript check --fix 会改写另一种:

  • 类型、模型、枚举、错误或作业直接使用名称,不加 $:$text->convert(from: json, as: Repo)、User->create(name: 'Joan')。$ 用于读取变量。
  • 可选字段通过其名称标记,即 age?: int,而不是其类型(age: int?)。对于可能为 null 的参数,仍使用 T?:fn show(repo: Repo?)。
  • 模型的选项写在其方括号中,即model User(unique: [email]) extends Timestamps { },而不是写在其代码块的行中。代码块中保存的是字段,即validate和fn。

调用该名称会生成每种类型的值:Repo($data)、Repo(name: 'x')、Age(7)、Size('small')、NotFound(id: 42)、SendWelcome(user_id: 7)。->from() 和 ->new() 已被移除,使用它们会产生错误(KS5003),其修复方式会写出该调用。

Edit this page on GitHub