I have a C# class (v9.0, nullable enabled) defined as
[Schema("Crypto")]
[DataContract]
public class Currency : AuditBase
{
[AutoId]
[DataMember, Required] public Guid Id { get; set; } = Guid.Empty;
[DataMember, Required] public string Name { get; set; } = "";
[DataMember] public string? Subname { get; set; } = null;
}
The generated TypeScript is
// @DataContract
export class Currency extends AuditBase
{
// @DataMember
// @Required()
public id: string|null; // why not string?
// @DataMember
// @Required()
public name: string|null; // why not string?
// @DataMember
public subname: string|null;
public constructor(init?: Partial<Currency>) { super(init); (Object as any).assign(this, init); }
}
In my main Program, I use the TypeScriptGenerator.UseNullableProperties = true;
I have two questions:
-
Why is the TS definitions of id and name have string|null instead of only string?
-
Is there a way to customise the TypeScriptGenerator, such that “//@ts-nocheck” can inserted once at the top TS file?
I forgot to add, my MSSQL database is predefined, so not generated from the C#.:
CREATE TABLE Crypto.Currency (
-- referential
Id UNIQUEIDENTIFIER DEFAULT NEWSEQUENTIALID(),
-- data
Name NVARCHAR(60) NOT NULL,
Subname NVARCHAR(60) NULL,
CONSTRAINT crypto_currency_pk PRIMARY KEY NONCLUSTERED (Id)
)