Skip to content

Make generated code smaller by putting reusable strings to constants or functions #128

Open
@zdila

Description

@zdila

When I read the generated code it often repeats strings like "validation failed at ", ": there are no valid alternatives", ": expected an object" and many more. Putting those to const variables and then using only those consts instead should help to reduce the size. Or maybe better to create error message builder functions like this:

function expectedProperty(path, property) {
  return `validation failed at ${path.join(".")}: expected '${property}' in object`;
}

Minifiers will also minify function and variable names.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions