Typescript-ref stopped working for IReturn<byte[]>

Hello

I am generating the file dtos.ts using typescript-ref tool

typescript-ref https://mds2.mojomotorcycles.com.au dtos.ts

For this model:

[Route("/admin-download-attachments")]
public class AdminDownloadAttachments : IReturn<byte[]>
{
    public int VehicleTransactionId { get; set; }
}

The issue is that I am getting this : IReturn<string>

// @Route("/admin-download-attachments")
export class AdminDownloadAttachments implements IReturn<string>
{
    public vehicleTransactionId: number;
    public constructor(init?: Partial<AdminDownloadAttachments>) { (Object as any).assign(this, init); }
    public createResponse() { return ''; }
    public getTypeName() { return 'AdminDownloadAttachments'; }
}

instead of this: IReturn<Uint8Array>

// @Route("/admin-download-attachments")
export class AdminDownloadAttachments implements IReturn<Uint8Array>
{
    public vehicleTransactionId: number;
    public constructor(init?: Partial<AdminDownloadAttachments>) { (Object as any).assign(this, init); }
    public createResponse() { return new Uint8Array(0); }
    public getTypeName() { return 'AdminDownloadAttachments'; }
}

The file is updated when I run the command

/* Options:
Date: 2021-08-06 07:44:28
Version: 5.110
Tip: To override a DTO option, remove "//" prefix before updating
BaseUrl: https://mds2.mojomotorcycles.com.au

//GlobalNamespace: 
//MakePropertiesOptional: False
//AddServiceStackTypes: True
//AddResponseStatus: False
//AddImplicitVersion: 
//AddDescriptionAsComments: True
//IncludeTypes: 
//ExcludeTypes: 
//DefaultImports: 
*/

Can you try clearing your packages cache and redownloading the latest v5.11 packages on MyGet:

$ nuget locals all -clear

As byte[] return types should return Blob by default as it provides greater flexibility in handling binary data.

Should you wish, you can configure it to return a Uint8Array instead with:

TypeScriptGenerator.ReturnTypeAliases[typeof(byte[]).Name] = "Uint8Array";

Thank you for your support. It works a treat.

I am now getting a Blob

// @Route("/admin-download-attachments")
export class AdminDownloadAttachments implements IReturn<Blob>
{
    public vehicleTransactionId: number;
    public constructor(init?: Partial<AdminDownloadAttachments>) { (Object as any).assign(this, init); }
    public createResponse() { return new Blob(); }
    public getTypeName() { return 'AdminDownloadAttachments'; }
}

I am happy with a Blob vs Uint8Array
I can then use it directly and remove the line

var blob = new Blob([response]);

2 Likes