# schema_salad.typescript_codegen

TypeScript code generator for a given schema salad definition.

## Attributes

`prims` |

## Classes

`TypeScriptCodeGen` | Generation of TypeScript code for a given Schema Salad definition.

## Functions

`doc_to_doc_string`(doc[, indent_level]) | Generate a documentation string from a schema salad doc field.

## Module Contents

schema_salad.typescript_codegen.doc_to_doc_string(doc, indent_level=0)

  Generate a documentation string from a schema salad doc field.

  Parameters:

    - doc (str | None)

    - indent_level (int)

  Return type:

    str

schema_salad.typescript_codegen.prims: Final

class schema_salad.typescript_codegen.TypeScriptCodeGen(base, examples, target, package)

  Bases: `schema_salad.codegen_base.CodeGenBase`

  Generation of TypeScript code for a given Schema Salad definition.

  Parameters:

    - base (str)

    - examples (str | None)

    - target (str | None)

    - package (str)

  target_dir: Final
  main_src_dir: Final
  test_resources_dir: Final
  package: Final
  base_uri: Final
  record_types: Final[set[str]]
  modules: Final[set[str]]
  id_field = ''
  examples: Final
  prologue()

    Trigger to generate the prolouge code.

    Return type:

      None

  static safe_name(name)

    Generate a safe version of the given name.

    Parameters:

      name (str)

    Return type:

      str

  begin_class(classname, extends, doc, abstract, field_names, idfield, optional_fields)

    Produce the header for the given class.

    Parameters:

      - classname (str)

      - extends (collections.abc.MutableSequence[str])

      - doc (str)

      - abstract (bool)

      - field_names (collections.abc.MutableSequence[str])

      - idfield (str)

      - optional_fields (set[str])

    Return type:

      None

  end_class(classname, field_names)

    Signal that we are done with this class.

    Parameters:

      - classname (str)

      - field_names (list[str])

    Return type:

      None

  type_loader(type_declaration, container=None, no_link_check=None)

    Parse the given type declaration and declare its components.

    Parameters:

      - type_declaration (list[Any] | dict[str, Any] | str)

      - container (str | None)

      - no_link_check (bool | None)

    Return type:

      schema_salad.codegen_base.TypeDef

  type_loader_enum(type_declaration)

    Build an enum type loader for the given declaration.

    Parameters:

      type_declaration (dict[str, Any])

    Return type:

      schema_salad.codegen_base.TypeDef

  declare_field(name, fieldtype, doc, optional, subscope)

    Output the code to load the given field.

    Parameters:

      - name (str)

      - fieldtype (schema_salad.codegen_base.TypeDef)

      - doc (str | None)

      - optional (bool)

      - subscope (str | None)

    Return type:

      None

  declare_id_field(name, fieldtype, doc, optional)

    Output the code to handle the given ID field.

    Parameters:

      - name (str)

      - fieldtype (schema_salad.codegen_base.TypeDef)

      - doc (str | None)

      - optional (bool)

    Return type:

      None

  to_typescript(val)

    Convert a Python keyword to a TypeScript keyword.

    Parameters:

      val (Any)

    Return type:

      Any

  uri_loader(inner, scoped_id, vocab_term, ref_scope, no_link_check=None)

    Construct the TypeDef for the given URI loader.

    Parameters:

      - inner (schema_salad.codegen_base.TypeDef)

      - scoped_id (bool)

      - vocab_term (bool)

      - ref_scope (int | None)

      - no_link_check (bool | None)

    Return type:

      schema_salad.codegen_base.TypeDef

  idmap_loader(field, inner, map_subject, map_predicate)

    Construct the TypeDef for the given mapped ID loader.

    Parameters:

      - field (str)

      - inner (schema_salad.codegen_base.TypeDef)

      - map_subject (str)

      - map_predicate (str | None)

    Return type:

      schema_salad.codegen_base.TypeDef

  typedsl_loader(inner, ref_scope)

    Construct the TypeDef for the given DSL loader.

    Parameters:

      - inner (schema_salad.codegen_base.TypeDef)

      - ref_scope (int | None)

    Return type:

      schema_salad.codegen_base.TypeDef

  epilogue(root_loader)

    Trigger to generate the epilouge code.

    Parameters:

      root_loader (schema_salad.codegen_base.TypeDef)

    Return type:

      None

  secondaryfilesdsl_loader(inner)

    Construct the TypeDef for secondary files.

    Parameters:

      inner (schema_salad.codegen_base.TypeDef)

    Return type:

      schema_salad.codegen_base.TypeDef