Table of Contents

Class TsModule

Namespace
TypedRest.CodeGeneration.TypeScript.Model
Assembly
TypedRest.CodeGeneration.TypeScript.dll

A TypeScript module that a type can be imported from.

public sealed class TsModule : IEquatable<TsModule>
Inheritance
object
TsModule
Implements

Properties

FilePath

The path of the file holding this module, relative to the output directory.

public string FilePath { get; }

Property Value

string

Exceptions

InvalidOperationException

The module is not generated by this tool.

IsGenerated

Indicates whether this module is generated by this tool rather than provided by a package.

public bool IsGenerated { get; }

Property Value

bool

Name

The last segment of the Specifier, which for a generated module is the name of the type it declares.

public string Name { get; }

Property Value

string

Specifier

The module specifier. For generated modules this is the file path without the extension.

public string Specifier { get; }

Property Value

string

Methods

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

Equals(TsModule?)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(TsModule? other)

Parameters

other TsModule

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

External(string)

A module provided by a package, e.g. typedrest/endpoints/generic.

public static TsModule External(string specifier)

Parameters

specifier string

Returns

TsModule

Generated(string)

A module generated by this tool, identified by its file path relative to the output directory without the .ts extension, e.g. dtos/Contact.

public static TsModule Generated(string path)

Parameters

path string

Returns

TsModule

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

RelativeTo(string)

Returns the specifier to use when importing this module from the file at fromFilePath.

public string RelativeTo(string fromFilePath)

Parameters

fromFilePath string

The path of the importing file relative to the output directory, e.g. dtos/Contact.ts.

Returns

string

Remarks

Generated modules get a relative specifier without a file extension. External modules are returned as-is. This deliberately does not use Path, which would emit backslashes on Windows.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

WithName(string)

Returns a copy of this module in the same directory but with a different Name.

public TsModule WithName(string name)

Parameters

name string

Returns

TsModule