Function typescript_type_def::write_definition_file
source · pub fn write_definition_file<W, T>(
writer: W,
options: DefinitionFileOptions<'_>
) -> Result<Stats>
Expand description
Writes a TypeScript definition file containing type definitions for T
to
the given writer.
The resulting TypeScript module will define and export the type definition
for T
and all of its transitive dependencies under a root namespace. The
name of the root namespace is configurable with the
root_namespace
option. Each type
definition may additionally have its own nested namespace under the root
namespace. The root namespace will also be the default export of the module.
If the root namespace is set to None
, no root namespace and no default
export will be added. See the docs of
root_namespace
for an important
note about using no root namespace.
The file will also include a header comment indicating that it was
auto-generated by this library. This is configurable with the
header
option.
Note that the TypeScript code generated by this library is not very human-readable. To make the code human-readable, use a TypeScript code formatter (such as Prettier) on the output.