Typescript reference generating types in wrong order

Hi,

I am using Add Typescript reference to create concrete dtos.ts file. I am also using AutoQuery via QueryDb. Within the dtos.ts file is generated, the export class QueryBase is being declared after my AutoQuery DTO - which is:

 [Route("/api/execs")]
public class QueryExecs : QueryDb<Executive>
{
    public long? Id { get; set; }
    public string LastnameStartsWith { get; set; }
    public string FirstnameStartsWith { get; set; }
}

As a result, when the generated js is run, it generates a “Cannot read property ‘prototype’ of undefined”.

Looking at your techstacks demo, the QueryBase is being declared before any QueryDb and this is before any implementations so all works. Is there any way I can control the order in which this code is generated?

I’m using v4.5

Thanks

G

That’s unfortunate types in the same module are order dependent. I’ve changed it so TypeScript generates types in order by deps in this commit.

You will also be able to control what types are generated in what Order with the new FilterTypes property on all Native Type Generators, e.g:

TypeScriptGenerator.FilterTypes = types => types
    .Where(x => x.Name != "ExcludeType")
    .OrderBy(x => x.Name).ToList();

This change is available from v4.5.1 that’s now available on MyGet.

…and that is why servicestack is a bargain. Thanks for speedy repsonse & resolution.

1 Like