KScript docs
EN

Error codes

KS6014

A type written the long way. An error in a .kscript file. Each of these has one form, and kscript check --fix rewrites the other:

  • A type, model, enum, error or job is named bare, without $: $text->convert(from: json, as: Repo), User->create(name: 'Joan'). $ reads a variable.
  • An optional field is marked on its name, age?: int, not on its type (age: int?). T? stays for a parameter that may be null: fn show(repo: Repo?).
  • A model's options go in its brackets, model User(unique: [email]) extends Timestamps { }, not as lines of its block. The block holds fields, validate and fn.

Calling the name makes a value of every kind of type: Repo($data), Repo(name: 'x'), Age(7), Size('small'), NotFound(id: 42), SendWelcome(user_id: 7). ->from() and ->new() are gone, and using one is an error (KS5003) whose fix writes the call.